Mongoose create multiple documents

后端 未结 4 908
粉色の甜心
粉色の甜心 2020-12-29 19:39

I know in the latest version of Mongoose you can pass multiple documents to the create method, or even better in my case an array of documents.

var array = [         


        
4条回答
  •  既然无缘
    2020-12-29 20:08

    You can access the variable list of parameters to your callback via arguments. So you could do something like:

    Candy.create(array, function (err) {
        if (err) // ...
    
        for (var i=1; i

提交回复
热议问题