kostberg
kostberg

Reputation: 133

How to nest documents into other documents

I'm working on a rest API app where I have a lot of different methods that do totally different things. I, therefore, decided that it would be a good idea to structurize my database into different folders, each folders storing different collections. I'm therefore looking to design a folder-like structure in my database to organize this and figured nesting documents into others would be the way to go. How can I do this? (I'm using express as my API framework for reference)

Upvotes: 1

Views: 42

Answers (1)

at07
at07

Reputation: 66

You should use mixed types and ObjectId types to design your schemas to create sub-doc and store references to other collections.

Please refer: https://mongoosejs.com/docs/schematypes.html

Hope this helps. If you give a more specific use case(description), will try to help you design your schema.

Upvotes: 2

Related Questions