简体   繁体   English

MongoDB 从数组中找到许多对象,使用匹配 id 的数组

[英]MongoDB find many objects from array, using array of matching id's

I have an array structures as such我有一个这样的数组结构

在此处输入图像描述

I've been trying to use an aggregation pipeline, and bulk.find() with a loop, and the $in operator, and none of these options seem to give me the power to (find many by an array of inputted id's).我一直在尝试使用聚合管道,以及带有循环的 bulk.find() 和 $in 运算符,但这些选项似乎都没有让我有能力(通过输入的 id 数组找到很多)。 How do you find many objects in an array filtering by an array of ID's that I already have?您如何通过我已经拥有的 ID 数组过滤数组中的许多对象? I'm using PyMongo我正在使用PyMongo

Using an aggregation pipeline, use an $in match after unwinding使用聚合管道,在展开后使用 $in 匹配

[
   {$unwind: "groups.asana"},
   {"source_id": {$in: ["id1", "id2", "id3"]}}
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 mongoDB 查询从对象数组中查找匹配元素 - How to find matching elements from an array of objects using mongoDB query 在对象数组中查找匹配 ID 的最佳方法? - Best way to find matching id's in an array of objects? 在具有 id 的数组与具有对象和相同 id 的数组之间查找匹配的 uniqueId - Find matching uniqueId between array with id's and array with objects and same id's 比较 2 个对象数组并找到匹配的颜色 id,然后创建一个新数组 Javascript - Compare 2 array's of objects and find matching color id's then create a new array Javascript MongoDB:如何在对象数组中找到_id $? - MongoDB: How to find _id $in array of objects? SQL查询从数组中查找具有尽可能多匹配的ID - SQL Query to find ID's with as many hits as possible from an Array 使用 nodejs 和 mongoose 从 mongodb 中具有 id 的对象数组中获取元素 - Get an element from an array of objects with an id in mongodb using nodejs and mongoose 迭代嵌套的对象数组,查找 id 并更新与 id 匹配的对象 - Iterate nested array of objects, find id and update object matching the id 在MongoDB中查找具有字符串ID数组的文档 - Find documents with array of string ID's in MongoDB MongoDB在对象数组中查找 - MongoDB find in array of objects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM