javascript - Getting error while updateing the document using mongoDB and node.js -


i getting following error while updating document using mongodb , node.js.

error:

typeerror: db.profile.updateone not function     @ exports.updateprofile (c:\xampp\htdocs\cit_node\route\route.js:101:13)     @ layer.handle [as handle_request] (c:\xampp\htdocs\cit_node\node_modules\e xpress\lib\router\layer.js:95:5)     @ next (c:\xampp\htdocs\cit_node\node_modules\express\lib\router\route.js:1 31:13)     @ route.dispatch (c:\xampp\htdocs\cit_node\node_modules\express\lib\router\ route.js:112:3)     @ layer.handle [as handle_request] (c:\xampp\htdocs\cit_node\node_modules\e xpress\lib\router\layer.js:95:5)     @ c:\xampp\htdocs\cit_node\node_modules\express\lib\router\index.js:277:22     @ function.process_params (c:\xampp\htdocs\cit_node\node_modules\express\li b\router\index.js:330:12)     @ next (c:\xampp\htdocs\cit_node\node_modules\express\lib\router\index.js:2 71:10)     @ immediate.<anonymous> (c:\xampp\htdocs\cit_node\node_modules\express-sess ion\index.js:433:7)     @ immediate.immediate._onimmediate (timers.js:425:18) 

i using mongojs driver connect mongodb.i explaining code below.

exports.updateprofile=function(req,res){     var colg_name=req.body.colg_name;     var colg_shname=req.body.colg_shname;     var address=req.body.address;     var cont_no=req.body.cont_no;     var email=req.body.email;     var id=req.body.id;     db.profile.updateone({_id:db.objectid(id)},{$set:{colgname:colg_name,colgsname:colg_shname,address:address,contno:cont_no,email:email}},function(err,docs){         if(!err){             if(docs){                 res.send("profile has updated suceessfully");             }         }         if(err){             res.send("profile not updated suceessfully");         }     }); } 

i following this link update record.please me resolve error.

you need access db object , collection objects profile collection. 1 way make connection in file called db.js , export db object can "required" other scripts or other way make updateprofile function accept db or collection object a parameter in function. error occurring because objects doesn't have properties think has.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -