假设我有以下收藏:
{
"_id":ObjectId("562e7c594c12942f08fe4192"),
"first":[
{
"shape":"square",
"color":"blue"
},
{
"shape":"circle",
"color":"red"
}
],
"second": []
}
我想做的是,首先在
first
排列并移动到
second
领域
db.collection.findOneAndUpdate({_id: ObjectId("562e7c594c12942f08fe4192")}, {$pull: {first: {color: "red"}}, $push: {// that specific object to second array}})