简体   繁体   中英

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). How do you find many objects in an array filtering by an array of ID's that I already have? I'm using PyMongo

Using an aggregation pipeline, use an $in match after unwinding

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM