monk - Using the value of a MongoDB field to update another field -


i have mongodb document structure this:

{     testvalue: 10,     maxvalue: 20 } 

i want set testvalue arbitrary integer value between 0 , maxvalue. ideally, this:

db.collection.update(     {},     {         $set: { 'testvalue': newvalue },         $min: { 'testvalue': 0 },         $max: { 'textvalue': $maxvalue }     } ) 

but doesn't work. there handful of threads relate question (e.g. update mongodb field using value of field), they're few years old, , can't find pertinent information in official documentation. there way want, or have use find() maxvalue separate call database using update()?

this still not possible in mongo 3.2 or lower, check example these jira tickets:

  1. self referential updates
  2. allow update compute expressions using referenced fields

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -