$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

随机推荐

  1. [CSS布局]3列布局:左右两列固定宽度、中间列自适应满宽

    一种常见的3列布局,左右两列固定宽度.中间列自适应满宽.整个网页不出现横向滚动条 纯CSS实现 效果图: 代码: <!DOCTYPE html> <html lang="e ...

  2. Eclipse Oxygen SVN Connector Setup

    新版的Eclipse(Oxygen)安装完Subversive后,现时无法自动安装SVN Connector,无论选择哪个都会自动关闭. 解决方法: Help -> Install New So ...

  3. 每天一个linux命令(网络):【转载】ping命令

    Linux系统的ping命令是常用的网络命令,它通常用来测试与目标主机的连通性,我们经常会说“ping一下某机器,看是不是开着”.不能打开网页时会说“你先ping网关地址192.168.1.1试试”. ...

  4. java面试题7

    1.重载和重写的区别? 重载(Overload):(1)方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载Overloading是一个类中多态性 ...

  5. Windows与.NET Framework、数据库版本对应关系

    ================== windows XP/server 2003 (.NET Framework与 SQL Server\Oracle) 支持.NET版本:.NET Framewor ...

  6. cocos2dx 3.0 +VS2013 环境搭建

    1.需要javasdk,android sdk,ndk,python 2.各种环境变量配置如下: JAVA_HOME:C:\Program Files\Java\jdk1.7.0_67 Path:%J ...

  7. Oracle基本操作命令

    一.Oracle监听命令 1.启动监听 lsnrctl start 五.Oracle 查看表空间的大小及使用情况sql语句 --1.查看表空间的名称及大小 SELECT t.tablespace_na ...

  8. jquery on() bind()绑定的点击事件在js动态新添加的元素生效

    方法一:$('.class').on("click",function(){……}); 相当于 $('.class').bind("click",functio ...

  9. 【python】 使用 setuptools

    不会安装python的egg文件,在网上搜索了一下,被“蟒蛇蛋”这个词雷到了,记录下. 随着对python的逐渐使用,发现一些python组件是用一个包管理器发布的,今天搞了快一个小时,终于搞定了,这 ...

  10. redis3.0自带集群配置

    参考 http://redis.readthedocs.org/en/latest/topic/cluster-tutorial.html http://yindashan.github.io/blo ...