{
"_id" : ObjectId("55a4b23636e6ba35079eb497"),
"userName" : "David",
"email" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e28683948b86a2858f838b8ecc818d8f">[email protected]</a>",
"image" : "https://lh5.googleusercontent.com/-ivBeNFeatn4/AAAAAAAAAAI/AAAAAAAABkk/aa86ghW9VRg/photo.jpg?sz=50",
"trade" : [
{
"selectedCar" : {
"model" : "Mikecar",
"year" : 77878,
"condition" : "hkjhkj",
"color" : "hkjhjkhjkhjk",
"_id" : "55a4b22d36e6ba35079eb496",
"imageUrl" : "http://cliparts.co/cliparts/Big/Kkz/BigKkzggT.png",
"userName" : "josh Smith",
"email" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="573d38243f17303a363e3b7934383a">[email protected]</a>"
},
"myCar" : {
"model" : "Son90098",
"year" : 879,
"condition" : "kjhjkhkhj",
"color" : "khjhjkhjk",
"_id" : "55a4b24036e6ba35079eb498",
"imageUrl" : "http://cliparts.co/cliparts/Big/Kkz/BigKkzggT.png"
},
"myEmail" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbdfdacdd2dffbdcd6dad2d795d8d4d6">[email protected]</a>"
},
"__v" : 2
}
User.findOneAndUpdate({'trade.myCar._id' : req.body.myCar._id }, {$pull: {'trade.$': {'trade.myCar._id' : req.body.myCar._id }}}, function(err,trade){
})
I need assistance in locating the nested id of an item within the embedded array trade
and removing all items where
trade.myCar._id = req.body.myCar._id
. The objective is to eliminate the entry that includes both the objects selectedCar
and myCar