Home > database >  Directing the value of a field divided by 2
Directing the value of a field divided by 2

Time:10-27

I have a collection called FOREIGN
I want to have one of these fields (volume) divided by 2 and then replace the original value of the
Such as the first original volume is 4194, I want to use 2097 to replace the 4194, the other fields unchanged
How to write this command?

CodePudding user response:

Couldn't find the method of direct, indirect method is
Db. FOREIGN. The find (). The forEach (e=& gt; {db. FOREIGN. UpdateOne ({_id: e. _id}, {$set: {volume: e.v olume * 2}})})
  • Related