How do you update a field value in Mongo to match a different field value in the same document?
I have several documents:
{"required" : 100, "total" : 30}
and I want to update the docs in such a way that require = total (regardless of the value of total). I tried:
db.collection.update({}, {"$set" : {"required" : "total"}})
but this sets it to the string literal "total", how do I access the value of the field, in this case 30
.
+3
source to share