首页 > 其他 > 详细

$in 操作符

时间:2015-10-21 22:40:03      阅读:356      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!