-
$in
-
The $in operator selects the documents where the valueof a field equals any value in the specified array. To specify an$in expression, use the following prototype:
For comparison of different BSON type values, see the specifiedBSON comparison order.
{ field: { $in: [<value1>, <value2>, ... <valueN> ] } }
If the field holds an array, then the $in operatorselects the documents whose field holds an array that containsat least one element that matches a value in the specified array(e.g. <value1>, <value2>, etc.)
上面这段话是摘自官方的解释,大概的意思就是说:field只要和array中的任意一个value相同,那么该文档就会被检索出来。
也就是说mongoDB中$in的功能和sql中的in是相同的。