Wednesday 20 November 2019

Express-Mongoose-MongoDB Question

Hello everyone, I am building some back-end services for a photography portfolio React app I am working on and would like to optimize my DB a bit more. Right now I have several documents, each with a container array, in a single collection that store image objects. Unfortunately, I am a bit new to Express/Mongoose so I was wondering what the code would look like for me to save a document into a completely separate collection, in the same DB, based off the genre of the image object that is send from the React client. Furthermore, I am also curious what the code would be to access a specific collection and then find an image object by id. Please note, that the ultimate goal here is to segregate image objects based off their genre so, for example, there would be an aerial collection that simply stores image documents. This method of storage would greatly simplify my current solution AND remove the need for me to store images within a container document's array.For reference, I am building all of my routes and async helper functions in a routing module that gets imported as middleware in the main app.js file. For reference, here is the Github for my source code: https://github.com/bryantb2/photographyReactApp/tree/master/server​Seriously, thanks a ton to anybody that can help with this!

Submitted November 21, 2019 at 07:08AM by DELGODO7

No comments:

Post a Comment