Hi,
Good day !
We want to Model Tree Structures along the lines of Child References where Children will be separate collections.
**database_for_products collection** : -> Collection stores documents having product and child collection name
-------------------------------------------------------------------
{
product_name: "<product1>",
childCollectionName : "<database_for_product1>"
},
{
product_name: "<product2>",
childCollectionName : "<database_for_product2>"
}
-------------------------------------------------------------------
In **database_for_product<m> collection** : -> Collections stores documents having team working on product<m> where m is the mth product, for example
-------------------------------------------------------------------
{
user_name: "<user1>",
childCollectionName : "<database_for_user1>"
},
{
user_name: "<user2>",
childCollectionName : "<database_for_user2>"
}
-------------------------------------------------------------------
In **database_for_user<j> collection** : -> Collection stores documents having services under user<j> under product <m>
-------------------------------------------------------------------
{
service_name: "<service1>",
last_release_date: "12/03/2021",
childCollectionName : "<database_for_service1>"
},
{
service_name: "<service2>",
last_release_date: "13/03/2021",
childCollectionName : "<database_for_service2>"
}
-------------------------------------------------------------------
In **database_for_service<k> collection** :-> Collection store documents having Runs under service <k>
-------------------------------------------------------------------
{
run_id: 123 ,
status : "Success",
log: "log location"
}
-------------------------------------------------------------------
We cant store them https://www.mongodb.com/docs/manual/tutorial/model-tree-structures-with-child-references/ as the attributes/columns in documents belonging at different hierarchies may be different
(I know MongoDB supports this, but we feel it will be cleaner if there is logical separation )
Now, with this structure how to implement * operator or use lookup functions ?
For example if we want all services under product1
Query : Product = Product1 , User = *, Service = *
Ans : [
{
Product:Product1,
User:User1,
Service:Service1
},
{
Product:Product1,
User:User1,
Service:Service2
},
{
Product:Product1,
User:User2,
Service:Service3
},
{
Product:Product1,
User:User2,
Service:Service4
}
]
Can someone please share how to use lookup/grpahlookup functions with our structure ?
Thanks,
Vachas