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

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -