I need query data from collection a first, then according to those data, query from collection b. Such as:
For each id queried from a query data from b where
You'll need to do it as two steps.
Look into the $in operator (reference) which allows passing an array of _ids for example. Many would suggest you do those in batches of, say, 1000 _ids.
$in
_id
db.myCollection.find({ _id : { $in : [ 1, 2, 3, 4] }})