Reputation: 141
I'm trying to obtain all objects that have an especific object in a collection. Example:
Object Company has a collection of Employees, and I want to find all Companies who have a especific Employee on this collection. What I'm trying to do is:
Company.find({where:{employees: {contains: employeeX}}}, function (err, companies) {
...
});
But it's not working.
Upvotes: 0
Views: 295
Reputation: 2019
var criteria = { "employees":{$in: [{employeeId:employeeXId}]}};
User
.find(criteria)
.then(function(data){
//Employee Collection
})
This works for me
Upvotes: 1