'Editing Large Collection in MongoDB

I am trying to edit an entire collection in my MongoDB Database. The collection is about 12k documents in size. I was trying to edit the files from my angular controller

let promises = [];
array.forEach(each => {
   promises.push(this.commonService.postObject('editObject', each));
});
forkJoin(promises).subscribe(data =>{})

My node function

module.exports.editObject = (model) =>{
  return function (req, res, next) {
    model.findOneAndUpdate({
      '_id': req.body._id
    }, req.body, {
      upsert: true
    }, function (err, doc) {
      if (err) return res.send(500, {
        error: err
      });
      return res.send(req.body);
    });
  };
}

But I get the error Message

ERR_INSUFFICIENT_RESOURCES

Is there a smarter way to do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source