2

Possible Duplicate:
Update MongoDB field using value of another field

For database migrations I always found it helpful to issue something like this in SQL:

UPDATE users SET full_name = users.first_name || " " || users.last_name (PL/SQL) or UPDATE users SET full_name = CONCAT( users.first_name, users.last_name ) (MySQL)

How do I do this in MongoDB without fetching all documents first and update them by iteration?

Community
  • 1
  • 1
Stefan
  • 3,382
  • 4
  • 23
  • 27
  • So what **obviously doesn't work** but looks like the syntax I need is this: `col.update({type:'user'}, {$set: {'full_name': this.first_name + " " + this.last_name} }, true, false);` – Stefan Oct 09 '12 at 11:31
  • 1
    also see this one: http://stackoverflow.com/questions/3788256/mongodb-updating-documents-using-data-from-the-same-document/3792958 – Chris Fulstow Oct 09 '12 at 11:40
  • yep. That's definitely duplicate. Didn't find those questions, though :( Thanks for pointing – Stefan Oct 09 '12 at 12:02

0 Answers0