0

I am new to using mongodb, I have a collection of users, I want every user to upload some of their photos. So, I am thinking of creating property called images for every user document. this would be an array of images. However, I don't know if it's applicable or not, or how to do so. Any ideas? I am using node.js

Mee
  • 1,413
  • 5
  • 24
  • 40
  • 1
    For some performance, latency and verbose implementation reasons you could/should avoid storing images in db altogether. Instead use file system/storage service to store the photos to a location using neat utility like [multer](https://www.npmjs.com/package/multer) and maintain a unique identifer reference of that location in the db for a user's photo retrieval. – ambianBeing Aug 01 '20 at 05:59

1 Answers1

0

There multiple libraries that are created to help store images in a MongoDB database. You can see some at this question: Store images in a MongoDB database

Also, for good design, you should consider having the images property containing IDs that correspond to the image, instead of the actual images themselves; it would be named imageIds.

Ederic Oytas
  • 139
  • 5