Suppose I have the following collection:
{
"_id":ObjectId("562e7c594c12942f08fe4192"),
"first":[
{
"shape":"square",
"color":"blue"
},
{
"shape":"circle",
"color":"red"
}
],
"second": []
}
What I want to do is, first find a specific object inside the first array and move that to second field
db.collection.findOneAndUpdate({_id: ObjectId("562e7c594c12942f08fe4192")}, {$pull: {first: {color: "red"}}, $push: {// that specific object to second array}})