I need to search through one MongoDB collection
let Firm= await Firm.find({"email":"[email protected]"});
and then, based on the results, which is a array, I need to filter through another collection.
I need to get all objects from another collection, based on all objects that are in the array which I just received.
The only way how to achieve this which I was able to do it is a for cycle:
let Invoices=[];
for (let i=0; i<Firms.length;i++){
let Results= await Invoice.find({ "firm_id":Firms[i].firm_id});
Invoices=Invoices.concat(Results);
}
But thats pretty ineffective. Can you think of a quicker way?