Good afternoon, I'm in need of help from someone who has experience with MongoDB to get me out of a doubt. I'm studying about MongoDB and I came across the following problem:
I have 2 Collections:
Customers and Users
Each client has its list of users referenced by the respective ObjectID. Each user has an Owner field to identify the Client that it belongs to.
The issue is that I need to create a structure where a client can be the parent of other clients, ie on my client object I will have a [Children] property, where it will contain the ObjectID of each Son, and will also have the owner field to identify if it is someone's child.
My problem is: How to filter all users who are mine and the users who are my children and my children's children, and so on.
I need to create this architecture in MongoDB and I have no idea how to do it, I'm using Node.JS + Mongoose + MongoDB.
Thanks in advance for your help.