0

How can I find all the documents of a given array of Id's. What I wanted is something like this:

for (let y = 0; y < dadosORS_id.length; y++) {
    mongoClient.collection('registosORS', function(err, collection) {
      collection.find({ id: dadosORS_id[y] }).toArray(function(err, result) {

     }) 
    }) 
  }) 
} 

but it's not working.

EFO
  • 173
  • 1
  • 10
  • Remove the outer loop and just do `mongoClient.collection('registosORS', function(err, collection) { collection.find({ 'id': { '$in': dadosORS_id } }).toArray(function(err, result) { }) })` – chridam Jan 03 '18 at 11:50
  • Thanks. I believe this was answered in another thread. – EFO Jan 03 '18 at 11:59

0 Answers0