arrays - 在 MongoDB 的数组数据中查找数组

标签 arrays mongodb

我想在此文档组中查找:

      "document": {
        "groups": [
          {
            "id": "5ccd5f7f34f82b0e3315b2f6"
          },
          {
            "id": "73b43unbfkfmdmddfdf84jjk"
          }
         ]
      }

包含我的一些查询数组组ID:

[ '5ccd5f7f34f82b0e3315b2f6',
 '5cdeded7ace07216f5873b5d',
 '5cdee5d114edac2cc00bb333' ]

最佳答案

一个简单的查找查询就足够了:

db.collection.find({ 'groups.id' : {$in : [ '5ccd5f7f34f82b0e3315b2f6',
                                            '5cdeded7ace07216f5873b5d',
                                            '5cdee5d114edac2cc00bb333' ] }})

关于arrays - 在 MongoDB 的数组数据中查找数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197501/

相关文章:

c++ - 在 C++ 中 : why does a constructor get called when an array of objects is declared?

c - 将文本文件输入到c中的二维数组中

PHP/MySQL - 交叉引用 mysql_fetch_array 数据

C++ 初始化字符串数组

arrays - 制作一个包含字符串和整数范围的数组合并

javascript - 在 Angular 应用程序的 API 调用中处理发送两个参数

security - 无法使用 MongoDB super 用户从终端连接到其他数据库

mongodb - 如何在 Node 蒙古语上使用 dropIndex() ?

c++ - Windows LNK2001 : unresolved external symbol __imp_mongoc_read_prefs_new 中的 Mongocxx

javascript - 如何从数组元素创建对象以传递到 mongoose 和 node.js 中的 mongodb 聚合?