mongodb - Mongo DB update query throwing error -


i have been trying update 1 filed using update query has throwing error , please help.

query:     db.dumpbasiccompany.update(     db.dumpbasiccompany.aggregate([{ $lookup: { from: "basiccompany", localfield: "companyname",  foreignfield: "companyname", as: "inventory_docs"}},{ $project : {"_id":1 } } ]),     { $set:{ flag: 1 } })       error:     writeresult({             "nmatched" : 0,             "nupserted" : 0,             "nmodified" : 0,             "writeerror" : {                     "code" : 2,                     "errmsg" : "cannot compare undefined"             }     }) 

i new people of mongo db not sure , kindly validated query.

you can use code this:

db.basiccompany.find().foreach(     function(doc) {         var check = false;         data = db.dumpbasiccompany.find({             companyname: doc.companyname         }).foreach(function(mydoc) {             if (mydoc != null) {                 check = true;             }         })         if (check == true) {             db.basiccompany.update({                 _id: doc._id             }, {                 $set: {                     flag: 1                 }             });         }     }); 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -