{
    "_id" : ObjectId("5da6ea7228cc5e07b48173a5"),
    "name" : "Joshi",
    "email" : "[email protected]",
    "password" : "4emc9122",
    "phone" : "6281900441",
    "myAddresses" : [
        {
            "_id" : ObjectId("5da6eb511e21bf07ce33a868"),
            "address" : "Office",
            "firstName" : "joshi",
            "lastName" : "g",
            "country" : "India",
            "city" : "VISAKHAPATNAM",
            "province" : "Andhra Pradesh",
            "postalCode" : 521344,
            "phoneNumber" : 8186912006.0,
            "address1" : "D.no:11/528-63,",
            "address2" : "santhi nagar, gurudwara"
        },
        {
            "_id" : ObjectId("5da6ec5e20a5db07da27fac6"),
            "address" : "Home",
            "firstName" : "joshi",
            "lastName" : "g",
            "country" : "India",
            "city" : "Vijayawada",
            "province" : "Andhra Pradesh",
            "postalCode" : 521333,
            "phoneNumber" : 8186912006.0,
            "address1" : "D.no:11-41,",
            "address2" : "main road, kalidindi"
        }
    ],
    "__v" : 0
}

最佳答案

您可以使用以下内容:

CollectionName.update({'myAddresses._id': "Your ID"}, {'$set': {
    'myAddresses.$. address': 'updated Address'
}}, function(err) { ...

09-25 21:40