Reputation: 2382
How do I query another collection in the reduce step based on the results of the map?
I have a name/type combination in one collection, and I need to add some fields to this collection as a look-up from another collection on a this combination. I was under the impression that it's possible, but the documentation says that reduce or map cannot access the database for any reason.
I can do this in code, but was wondering if i can use the map-reduce interface directly in mongo.
Basically, the steps are:
Upvotes: 0
Views: 95
Reputation: 42352
You cannot query another collection during reduce phase.
Basically, reduce exists to combine all collective emitted output values for each unique key you are aggregating by.
There are no joins or pseudo-joins in MongoDB so this all has to be done on the application side.
Upvotes: 1