$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. 单链表是否有环的问题解决与讨论(java实现)

    单链表是否有环的问题经常在面试中遇到,一般面试中会要求空间为O(1);再者求若有环,则求环产生时的起始位置. 下面采用java实现. //单链表class ListNode{ int val; Lis ...

  2. pshell远程连接服务器

    在页面添加ip    和 端口  还有 用户,我这里填的是服务器root用户 成功之后 端口后是可以改的   首先看下ssh是否启动  rpm -qa | grep ssh 有的话就是vi /etc/ ...

  3. Eclipse 项目有红惊叹号

    Eclipse 项目有红感叹号原因:显示红色感叹号是因为jar包的路径不对 解决:在项目上右击Build Path -> Configure Build Paht...(或Propertise- ...

  4. react中findDOMNode

    在使用react过程中,大家有时会那么这里的findDomNode是做什么的呢? import { findDomNode } from 'react-dom'; 简单来说是用来得到实际Dom的,因为 ...

  5. CH3401 石头游戏

    题意 3401 石头游戏 0x30「数学知识」例题 描述 石头游戏在一个 n 行 m 列 (1≤n,m≤8) 的网格上进行,每个格子对应一种操作序列,操作序列至多有10种,分别用0~9这10个数字指明 ...

  6. kudu yum 安装

    yum 源 http://archive.cloudera.com/kudu/redhat/7/x86_64/kudu/cloudera-kudu.repo [cloudera-kudu] # Pac ...

  7. php解析HTML

    PHP Simple HTML DOM 解析器显然是相当不多的html文件解析工具.他能够在server端採用相似于jquery的方式进行dom查找和改动.眼下这个解析器支持PHP5. 可是,这个首先 ...

  8. bzoj 2839 集合计数——二项式反演

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2839 设 \( g(i) \) 表示至少有 i 个, \( f(i) \) 表示恰好有 i ...

  9. CentOS 7 安装Memcached服务

    Memcached 简介 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站 ...

  10. 【pc杂谈】win7系统通过虚拟网卡共享wifi

    用管理员权限进入dos命令行 启用并设定虚拟WiFi网卡:netsh wlan set hostednetwork mode=allow  ssid=paulnet key=paulwinflo(注意 ...