0

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.

Sidney
  • 141
  • 5

1 Answers1

1
var criteria = { "employees":{$in: [{employeeId:employeeXId}]}};     

User
   .find(criteria)  
   .then(function(data){
      //Employee Collection
   })  

This works for me

Abhishek
  • 1,999
  • 5
  • 26
  • 52