2017-03-01 18 views
0

以下は私のコードです。私のDBを更新したいので、非同期を使用する必要がありますが、次のエラーを投げています: "TypeError:cbはE:\ smart-in-ffa (E:\ smart-in-ffa \ api \ node_modules \ mongojs \ node_modules \ mongodb \ lib \ utils.js:96:56) で\ apis \ node_modules \ mongojs \ lib \ collection.js:106:7 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 \ process._tickCallback(internal/process/next_tick.js:98:9)の_combinedTickCallback(internal/process/next_tick.js:67:7)のnode_modules¥mongodb-core¥lib¥connection¥pool.js:455:18 ) [nodemon] app crashed - ファイルchaを待っています開始する前に、NGES ...」以下Async.each throwing error

は私のコードです:

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); 
      } 
    }); 

答えて

0

これはあなたにエラーを与えていますが、あまりにも多くのパラメータとなるべきものを渡しているので、それはマングースださasync.eachではありません関数はオブジェクトです。

変更この:これに

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

:たくさんman.Itが働い

{ upsert: true, multi: true }, 
+0

感謝:) – Akshay

関連する問題