0

I have user schema

{
phone:'String'
}

My query field is phone and i have an array of phone numbers like this ['1233','2134','43433'] to query;

I had to query user collection that this phone numbers are present or not in collection...

I wanted to complete this operation in single query rather then using async.each or some asynchronous operation.

Is it possible with single operation?

3

1 Answer 1

0

You should use $in operator to find by phone

User.find({ phone : { $in : ['1233','2134','43433'] }}, function(err, users) {
  if(err) {
     //return error
  }
  console.log(users);
  //return success
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.