如何在mongodb中更新嵌套数组

时间:2017-10-03 10:39:10

标签: node.js mongodb

假设我们在集合中有以下数据

{
"_id" : ObjectId("59d1f9f366e0852538645961"),
"agentId" : ObjectId("59d1f9f366e0852538645960"),
"level" : 1,
"totalCommission" : 0,
"createDate" : "Mon Oct 02 2017 14:03:55 GMT+0530 (India Standard Time)",
"work" : [ 
    {
        "commission" : [],
        "project" : {},
        "enquiry" : {
            "createDate" : ISODate("2017-10-02T13:17:31.907Z"),
            "quarter" : {
                "_id" : ObjectId("59d21e2f5fa00a1734d9f847"),
                "type" : "4",
                "startMonth" : "October",
                "endMonth" : "December",
                "month" : "January",
                "DisbursementStartDate" : 15,
                "DisbursementEndDate" : 20,
                "__v" : 0
            },
            "enquiryId" : ObjectId("59d23c6bd5077719009c1d07")
        },
        "enquiryId" : ObjectId("59d23c6bd5077719009c1d07"),
        "createDate" : ISODate("2017-10-02T13:17:31.907Z"),
        "projectId" : ObjectId("59d245a27300631918cd7641")
    }
],
"__v" : 0

}

现在我想更新或推送"佣金"阵列存在于 阵列"工作"。

0 个答案:

没有答案