Update MongoDB field using value of another field -
in mongodb, possible update value of field using value field? equivalent sql like:
update person set name = firstname + ' ' + lastname
and mongodb pseudo-code be:
db.person.update( {}, { $set : { name : firstname + ' ' + lastname } );
you cannot refer document in update (yet). you'll need iterate through documents , update each document using function. see this answer example, or this one server-side eval()
.
Comments
Post a Comment