标签:
【$in 操作符】
The $in operator selects the documents where the value of a field equals any value in the specified array.
$in 选择包含指定值之一的 doc。
If the field holds an array, then the $in operator selects the documents whose field holds an array that contains at least one element that matches a value in the specified array
The $in operator can specify matching values using regular expressions of the form /pattern/. Youcannot use $regex operator expressions inside an $in.
Consider the following example:
db.inventory.find( { tags: { $in: [ /^be/, /^st/ ] } } )
This query selects all documents in the inventory collection where the tags field holds an array that contains at least one element that starts with either be or st.
参考:https://docs.mongodb.org/manual/reference/operator/query/in/#op._S_in
标签:
原文地址:http://www.cnblogs.com/tekkaman/p/4899084.html