I
I
iffkomc2016-03-26 06:01:40
Mongoose
iffkomc, 2016-03-26 06:01:40

How to find a document by multiple mongoose array values?

Hello! Help not a crutch method to find a document of this kind. I am attaching my crutch method for understanding =) Event.find({tags: 'angular', tags: 'dom'}, func(err,docs){...}) So I have two array elements that I want to find a document. Advise the appropriate option))

Event.create({name: 'Курсы', id: 2, tags: ['webmanufacture', 'dom', 'JS', 'angular'], geo: {x: 10, y:10}}, function(){
   console.log('created event!');
 });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iffkomc, 2016-03-26
@iffkomc

Found a solution:

Event
  .find({
    tags: { $in: ['angular', 'dom']}
    }, function(err, docs){
  if(err) throw err;
  else console.log(docs);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question