0

I'm using MongoDB for an e-commerce site and we're planning on using GridFS to store product images.

When using GridFS, would it be better practice to store the product descriptions, pricing, etc. as meta data? or would you have Products collection that would store all of this and you would just store the product id in the meta data?

Haven't used GridFS before so really appreciate any comments.

1 Answer 1

1

If you decide to store the product description as metadata in the files collection, it may be inconvenient if you have multiples images of the same product, as you'll end up having to duplicate that product info to put in each image's metadata document.

Store the product information in its own collection. Then in gridFS, add a field to each image's metadata which stores the _id for the product it belongs to. With this strategy, you will be able to retrieve all the images for a given product by a single query on this field.

Here's a link to some other helpful gridFS questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.