I had taken this array
arr = ["1","2"]
And I want to find this id’s are present in mongodb in user collection or not,
So how do I write query in mongoose for that?
user.find({'empid':'arr'},(err,res))
I am doing like this.
I had taken this array
arr = ["1","2"]
And I want to find this id’s are present in mongodb in user collection or not,
So how do I write query in mongoose for that?
user.find({'empid':'arr'},(err,res))
I am doing like this.
2
Answers
You should first loop through your array then run mongodb query to find item.
code should be some thing like this:
I think you are looking for the query operator
"$in"
.Here’s how you can do it.
Try it on mongoplayground.net.