码迷,mamicode.com
首页 > 其他好文 > 详细

$in 操作符

时间:2015-10-21 22:41:48      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:

$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

Use the $in Operator with a Regular Expression

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

$in 操作符

标签:

原文地址:http://www.cnblogs.com/tekkaman/p/4899084.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!