If I were to write this in SQL it would be (sort of):
SELECT *
FROM request req, response res
WHERE req.suites_test=res.key # join
AND res.version='2.0.b1662.5' # extra conditions
AND req.suites_id='58762c40664df86d2069e2c9'
In MongoDB I can do:
# a join between request and response
db.response.aggregate([{$lookup: {from: "request", localField: "key", foreignField: "suites.test", as: "matching"} } ])
# find all requests that match a condition
db.request.find( { "suites.id": ObjectId("58762c40664df86d2069e2c9") } )
# find all responses that match a condition
db.response.find( { "version": "2.0.b1662.5" } )
How can I combine the three in a single MongoDB query?