Is there a way to prevent expansion of an array containing relationships to other documents?

My program has a lot of nested objets and relationships and I want to be able to not expand these. It impacts the application quite a bit having to expand all of these relationships and then embed them into a single object.

Is there a way to prevent this?

Thanks!

Hi @Olle_Thunberg,

Data Modeling is a vaste topic in MongoDB and there are a few design patterns that can help a lot if they are used correctly.

I’d recommend to check the M320 Data Modeling course on MongoDB University: MongoDB Courses and Trainings | MongoDB University.

Or you can also checkout these blog posts on the developer hub that highlight the more famous ones (check the entire list at the bottom).

This one above (the outlier pattern) could potentially be a solution in your case for example. But there are many tricks available and they can also be combined sometimes. It’s really link to your use case and data model.

Cheers,
Maxime.