I have two mongoose collection. Let's consider collection-1
and collection-2
. They have data similar to following data
collection-1 :
{'name': 'Tom', 'age':20, 'bank-acc':1111},
{'name': 'Dick', 'age':25, 'bank-acc':2222},
{'name': 'Hary', 'age':22, 'bank-acc':3333}
Collection-2
{'bank-acc':1111, 'balance':100},
{'bank-acc':2222, 'balance':200},
{'bank-acc':3333, 'balance':300}
Now I want to query these both collections at the same time to get the names from collection-1 whose age is grater than 20 and have balance grater than 100 in collection-2.
Some people suggested me that because this is MongoDB which is a NO-SQL
database so I should combine these two tables into one and then try to query it but in my case, it's highly infeasible for me to combine these two tables with the real schema. I guess it could be possible using aggregate queries using lookup or similar keywords may be but I have searched in many places I have no idea what to search while finding the answer to this question. Can anybody give a sample aggregate query to search two tables at once?