I have an update statement using Mongoose, something like this:
Model.update(condition, {
foo: '1',
bar: '2',
baz: '3'
},
{
new: true,
upsert: true
}, function(err, result){
});
here is my conundrum - I only want to set the bar field if no document already exists. But always want to set the foo and baz fields, regardless.
Is there a way to do that with one query, or must I use more than one query to do this?