How can i replace all elements from a mongodb array element. As in below example, my requirement is to remove both object from skills array and add new elements in it.
{
"_id": "uniqueid",
"skills": [
{ "skill": "dancer" },
{ "skill": "singer" }
]
}
I need to replace all element of skills array field. How this can be achieved using mongodb java driver, or other query types?
db.colname.find({"_id": "uniqueid"}, {$set:{"skills":new array}})