Posts

Showing posts with the label mongo db

Routing Pattern PUT

I've been follow a tutorial about node js with express framework and mongo db, http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb/ , but it isn't complete, it miss put routing pattern, to edit users. this is routing pattern PUT. /* * PUT to updateuser */ router.put('/updateuser/:id',function(req,res){   var db=req.db;   var userToUpdate=req.params.id;   var doc = {$set: req.body}   db.collection('userlist').updateById(userToUpdate,doc,function(err,result){     res.send((result===1)?{msg:''}:{msg:'error: '+err});   }); }); module.exports = router; ... these tutorial use mogoskim to communicate with mongo, it was my way. other tutorial has a complete PUT, (editing user), http://garrilla.logdown.com/posts/192327-rest-follow-up-excercise