Async.each 抛出错误

Async.each throwing error

下面是我的代码,我想更新我的数据库,因此必须使用异步,但它抛出以下错误-“TypeError: cb is not a function.at E:\smart-in-ffa\apis\node_modules\mongojs\lib\collection.js:106 :7 在 handleCallback (E:\smart-in-ffa\apis\node_modules\mongojs\node_modules\mongodb\lib\utils.js:96:56) 在 E:\smart-in-ffa\apis\node_modules\mongojs\node_modules\mongodb\lib\collection.js:1048:5 在 E:\smart-in-ffa\apis\node_modules\mongojs\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:455:18 在 _combinedTickCallback (internal/process/next_tick.js:67:7) 在 process._tickCallback (internal/process/next_tick.js:98:9) [nodemon] 应用程序崩溃 - 在开始之前等待文件更改..."

下面是我的代码:

 async.each(jsondata,
        function(itemdata, callbackNew){
            //console.log(item);
            db.mdb.collection('Copy_of_counters')
                .update(
                {"store_code":itemdata.store_code},{$set:itemdata},
                { upsert: true },{ multi: true },
                function (erreach, data) {
                    if (erreach) {
                        console.log("error reported")
                        console.log(erreach)
                        callbackNew(erreach);
                    }
                    else{
                        console.log('Data updated')
                        callbackNew();
                        //app.send(req,res,data);
                    }
                })

        },function(err){
            if(err) {
                console.log("this is the error"+err)
                app.senderr(req,res,err);
            }
            else{
                app.send(req,res,jsondata);
            }
    });

这不是 async.each 给你的错误,而是 Mongoose,因为你传递了太多参数,而应该是函数的是对象。

改变这个:

{ upsert: true },{ multi: true },

对此:

{ upsert: true, multi: true },