Mongo DB查询管道

时间:2020-08-06 19:13:30

标签: mongodb mongoose mongodb-query aggregation-framework

我有一个mongo查询,例如:

"$lookup": {
            "from": "CollectionA",
             let: { fieldId: "A"},
            pipeline: [
              { $match:
                 { $expr:
                    { $and:
                       [
                         { $eq: [ "$A",  "$$A" ] },
                         { $eq: [ "$animals", "Cat" ] }
                       ]
                    }
                 }
              }
              ],
            "as": "sample_lookup"
        }
    },

在上面的查询中,我希望将动物作为列表,例如$ animals:$in["cat","dog","Rat"] ..不确定在查询级别上是如何完成的..请帮助我将此查询转换为接受动物作为列表,然后获取所有与任何动物相匹配的记录...

0 个答案:

没有答案