Venue.update({_id : venue.id},
{
name : venue.name,
'contact.phone' : venue.contact.formattedPhone
}, {upsert: true}).exec()
In this code, if venue has no phone, Upsert operation is not done. How can I avoid this? I want to update that field if it is not null, but if null, just dont include that field.
Edit:
Venue.update({_id : venue.id},
{
name : venue.name,
'contact.phone' : ((!venue.contact.formattedPhone)?
'' : venue.contact.formattedPhone)
}, {upsert: true, safe:false}).exec()
This code works fine but this time, 'phone' fields are ''. What I want is, hiding the field if it is undefined.