MongoDB: unconditional updates? -
this seems silly question haven't yet found answer. if wanted add same field->value every record in mongodb collection, appropriate shell command so? tried doing multi update blank query ({}) resulted in error:
multi update works $ operators
i'm bit puzzled how around this. suggestions?
the error says all: can modify multiple documents using $
modifier operators. had this:
> db.coll.update({ }, { a: 'b' }, false, true);
which replace first object in collection { a: 'b' }
if multi
false. wouldn't want replace objects in collection same document!
use $set
operator instead:
> db.coll.update({ }, { '$set': { a: 'b' } }, false, true);
this set a
property of every document (creating necessary) 'b'
.
Comments
Post a Comment