I have a collection as below and I wish to update the email with "@company.com" where type is "email" and Details is null.
{
"Name" : "Sam",
"Company" : "Awesomeness"
"Contacts" : [
{
"type" : "phone",
"Detail" : "1231232"
},
{
"type" : "email",
"Detail" : null
}
]
}
I have reached as far as
collection.update({"Contacts.type" : "email", "Contacts.Detail" : null},
{ $set :
{ "Contacts.$.Detail" :
{
$concat : [$Name , "@" , "$Company", ".com"]
}
})
but this gives an error saying $ dollar prefixed field "$concat" ....is not valid for storage.