Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose cursor eachasync

// Iterate over documents asynchronously
Thing.
  find({ name: /^hello/ }).
  cursor().
  eachAsync(async function (doc, i) {
    doc.foo = doc.bar + i;
    await doc.save();
  })
Source by mongoosejs.com #
 
PREVIOUS NEXT
Tagged: #mongoose #cursor #eachasync
ADD COMMENT
Topic
Name
8+1 =