Node.js Mongo更新不工作

Node.js Mongo更新不工作,node.js,mongodb,asynchronous,Node.js,Mongodb,Asynchronous,以下是我的更新代码: async.each(jsondata, function(itemdata, callbackNew){ itemdata.store_code=parseInt(itemdata.store_code); //console.log(itemdata.store_code); db.mdb.collection('counters') .updat

以下是我的更新代码:

 async.each(jsondata,
        function(itemdata, callbackNew){
             itemdata.store_code=parseInt(itemdata.store_code);
            //console.log(itemdata.store_code);
            db.mdb.collection('counters')
                .update(
                {"store_code": itemdata.store_code},{$set:itemdata},
                { upsert: 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);
            }
    });
但是数据库没有改变。更新前后的值是相同的。 下面是我的数据库的JSON

{ 
    "_id" : ObjectId("586aac4c8231ee0b98458045"), 
    "store_code" : NumberInt(10800), 
    "counter_name" : "R.N.Electric", 
    "address" : "314 khatipura road", 
    "locality" : "Khatipura Road (Jhotwara)", 
    "pincode" : "302012", 
    "town" : "JAIPUR", 
    "gtm_city" : "JAIPUR", 
    "sales_office" : "URAJ", 
    "owner_name" : "Rajeev", 
    "owner_mobile" : "9828024073", 
    "division_mapping" : [
        {
            "dvcode" : "cfc", 
            "dc" : "trade", 
            "beatcode" : "govindpura", 
            "fos" : {
                "_id" : ObjectId("586ab8318231ee0b98458843"), 
                "loginid" : "9928483483", 
                "name" : "Arpit Gupta", 
                "division" : [
                    "cfc", 
                    "iron"
                ], 
                "sales_office" : "URAJ", 
                "gtm_city" : "JAIPUR"
            }, 
            "beat" : {
                "_id" : ObjectId("586d372b39f64316b9c3cbd7"), 
                "division" : {
                    "_id" : ObjectId("5869f8b639f6430fe4edee2a"), 
                    "clientdvcode" : NumberInt(40), 
                    "code" : "cfc", 
                    "name" : "Cooking  & Fabric Care", 
                    "project_code" : "usha-fos", 
                    "client_code" : "usha", 
                    "agent_code" : "v5global"
                }, 
                "beatcode" : "govindpura", 
                "sales_office" : "URAJ", 
                "gtm_city" : "JAIPUR", 
                "active" : true, 
                "agency_code" : "v5global", 
                "client_code" : "USHA_FOS", 
                "proj_code" : "usha-fos", 
                "fos" : {
                    "_id" : ObjectId("586ab8318231ee0b98458843"), 
                    "loginid" : "9928483483", 
                    "name" : "Arpit Gupta", 
                    "division" : [
                        "cfc", 
                        "iron"
                    ], 
                    "sales_office" : "URAJ", 
                    "gtm_city" : "JAIPUR"
                }
            }
        }
    ], 
    "distributor_mail" : "sunil.todi@yahoo.in", 
    "project_code" : "usha-fos", 
    "client_code" : "usha", 
    "agent_code" : "v5global", 
    "distributor_name" : "Sundeep Electrical"
}
下面是我在更新中发送的文档($set:itemdata):


您确定您的数据库中只有一条记录用于该
存储\u code
?问题出在哪里?发送的数据和数据库结果在此细节中是相同的fields@throrin19
itemdata
中的
counter\u name
属性不同
store\u code
类型为
string
,但数据库具有相同类型的字段
long
。所以,
update
中的查询部分没有找到任何记录,也没有更新。
{ store_code: '10800',
  counter_name: 'R.N.Electrics',
  address: '314 khatipura road',
  locality: 'Khatipura Road (Jhotwara)',
  pincode: '302012',
  town: 'JAIPUR',
  gtm_city: 'JAIPUR',
  sales_office: 'URAJ',
  owner_name: 'Rajeev',
  owner_mobile: '9828024073',
  distributor_mail: 'sunil.todi@yahoo.in',
  distributor_name: 'Sundeep Electrical' }