Reputation: 177
F.e. I have three models:
ModelA, ModelB, ModelC
ModelA has an array with ids of instances of ModelB. ModelB has an array with ids of instances of ModelC.
How can I query all instances of ModelC that are members of all instances of ModelB that are members of instance of ModelA?
ModelA
∟ [
ModelB
∟ [ModelC, ModelC, ModelC]
ModelB
∟ [ModelC, ModelC, ModelC, ModelC]
]
Upvotes: 0
Views: 131
Reputation: 56467
Are ModelB
and ModelC
embedded documents? Or are they references? Assuming they are references, then you will have to first load all ModelA
instances and then load all ModelB
instances and so on. Unfortunetly MongoDB does not support joins, so there is nothing else you can do ( well, you can always try running map/reduce ). It looks like SQL database might be a better choice for whatever you are trying to do.
Upvotes: 2