examples/mongo/add-field-with-default-value.js

6 lines
152 B
JavaScript

db.getCollection('myCollection').update(
{$or:[{"name":null},{"name":{$exists:false}}]},
{$set:{"name":"default, value"}},
{multi:true}
);