Batch update with Mongoose

前端 未结 2 2146
伪装坚强ぢ
伪装坚强ぢ 2021-02-09 02:34

I\'m pulling data from a RETS(XML) feed and saving it in a local MongoDB using node and mongoose.

Periodically I need to update the documents and delete the inactive one

2条回答
  •  死守一世寂寞
    2021-02-09 03:31

    On MongoDB, to update multiple documents (not just one) using Mongoose you can use the multi option:

    Model.updateMany({ 
      size: 'lage'
    }, { 
      $set: { size: 'large' }
    });
    

    See more on in the Mongoose documentation for updating documents and here

提交回复
热议问题