Reputation: 848
I want to query mongoDB field for data that is '$in' two lists (arrays) kinda:
{user: {$in: [<array1>]} AND user: {$in: [<array2>]}}
so the query returns only those 'users' that present in both arrays.
I feel this isn't right:
{user: {$in: [<array1>], [<array2>]}}
Any ideas?
Upvotes: 0
Views: 2028
Reputation: 43265
Either you can use the $AND operator.
http://docs.mongodb.org/manual/reference/operator/query/and/
{'$AND':[ {'user':{$in: [<..array1..>]} },{'user':{$in: [<..array2..>] } }] }
Upvotes: 4