I’m just curious what’s difference between .in() and .all() methods in mongoose Query?
Can you explain by a simple example.
I’m just curious what’s difference between .in() and .all() methods in mongoose Query? Can
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is the explanation from mongodb.org:
$all
The $all operator is similar to $in, but instead of matching any value in the specified array all values in the array must be matched. For example, the object
{ a: [ 1, 2, 3 ] }
would be matched by
db.things.find( { a: { $all: [ 2, 3 ] } } );
but not
db.things.find( { a: { $all: [ 2, 3, 4 ] } } );
An array can have more elements than those specified by the $all criteria. $all specifies a minimum set of elements that must be matched.
Read more about mongodb operators here