Mongoose nested query on Model by field of its referenced model
You can’t do this in a single query because MongoDB doesn’t support joins. Instead, you have to break it into a couple steps: // Get the _ids of people with the last name of Robertson. Person.find({lastname: ‘Robertson’}, {_id: 1}, function(err, docs) { // Map the docs into an array of just the _ids var ids … Read more