2
I have a collection structured like this:
{
"_id": i43h21n5lk2354,
"createdAt" : ISODate("2018-08-19T16:56:31.555Z"),
"services" : {
"facebook" : {
....
name: "Michael Jackson"
....
....
}
I want to update the field name, but it erases all the rest of the document, I’m using so:
usersCollection.update(
{ _id: userId },
{
$set: {
services: {
facebook: {
name: "Jackson Michael"
}
},
}
})
After the update, and the only thing left is the name field, all the others disappear.
{
"_id": i43h21n5lk2354,
"createdAt" : ISODate("2018-08-19T16:56:31.555Z"),
"services" : {
"facebook" : {
name: "Jackson Michael"
}
Exactly, thank you
– Fernando