I have a Structured Collection like this:
{
"_id": i43h21n5lk2354,
"createdAt" : ISODate("2018-08-19T16:56:31.555Z"),
"services" : {
"facebook" : {
....
name: "Michael Jackson"
....
....
}
I want to give the update in the name field, but it deletes all the rest of the document,
usersCollection.update(
{ _id: userId },
{
$set: {
services: {
facebook: {
name: "Jackson Michael"
}
},
}
})
After the update, and only thing that remains is the name field, all others disappear.
{
"_id": i43h21n5lk2354,
"createdAt" : ISODate("2018-08-19T16:56:31.555Z"),
"services" : {
"facebook" : {
name: "Jackson Michael"
}