javascript - Update dependent Date field in Mongoose -


i have documents in mongoose (mongodb):

{   begin: date,   end: date } 

all i'd to:

  1. select documents end == null
  2. and update them using end = "begin increased 10 days"

how can done within single update?

right now, cannot reference document's current properties in update(). instead, you'll have iterate through documents as described in answer. in case, more this:

db.docs.find({end:null}).foreach(   function(doc) {     doc.end = doc.begin + 10;     db.docs.save(doc);   } ) 

this syntax mongo shell-- might have make changes mongoose, as per api.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -