Sorry for the delay! Let’s see if we can help you out.
Before we address how to manage related collections of data, as this is totally possible in MongoDB (we will get to this in a moment). However, this approach works great when using an RDBMS, but isn’t recommended when using MongoDB. I wrote more about this on the MongoDB Developer Hub . tl;dr: I would personally recommend embedding the role within the user document, unless you have a good reason to keep it separate, and I am not seeing a reason here (correct me if I’m wrong though
). Embedding this data directly is going to save you a lot of effort.
Alright, now that we’ve addressed the schema design, let’s address how to do this with your existing schema design. I want to address the issues in your OG post:
One of the downsides of keeping this data separate is that you will need to make at a minimum two queries to your database to get all the data you need. This isn’t bad, it’s just something that’s true in this case.
This is true, you will need to make a query for this.
This isn’t an issue, since Angular 2 follows the MVC pattern, so your data model should be kept separate from the controller on the frontend anyways. There is no need for the frontend to know what your data model on your backend looks like. So, this shouldn’t be an issue.
To sum up, I think it’s going to be more effective for us to discuss why you are separating our this data and figure out the best data model for you application. Looking forward to hearing from you!