📜  mongodb 聚合填充 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:05.435000             🧑  作者: Mango

代码示例1
Appointments.aggregate([{
        $group: {
            _id: '$date',
            patients: {
                $push: '$patient'
            }
        }
    },
    {
        $project: {
            date: '$_id',
            patients: 1,
            _id: 0
        }
    },
    {
        $lookup: {
            from: "patients",
            localField: "patient",
            foreignField: "_id",
            as: "patient_doc"
        }
    }
])