Mongdb Look让我们使用先前查找结果中的字段

时间:2019-06-19 05:49:10

标签: mongodb lookup

我要使用$ c.cid

此js如何工作?

此customer_url作为c,查找客户使用customer_url.cid

{
    $lookup: {
        from: "customer_url",
        localField: "url_id",
        foreignField: "url_id",
        as: "c"
    }
},
{
    $unwind: "$c"
},
{
    $lookup: {
        as: "customer",
        from: "customer_dim",
        let: {
            cid: "$c.cid"
        },
        pipeline: [
            {
                $match: {
                    $expr: {
                        $eq: ["$_id", "$$cid"]
                    }
                }
            }
        ]
    }
}

0 个答案:

没有答案