Friday 19 May 2017

how to count rows of particular column in nodejs

i have donatedate field in user schema,donatedate is changing everytime,everytime i want to display how many time i am changing donatedate.means when i update the date it returns the no.of
updation of donatedate.i am created api for change donatedate ,in that i want to display no.of chnaging donatedate.i am tesing through postman.

                  router.put('/donateDate/:username',function(req,res){
                  User.findOneAndUpdate({ username: req.params.username},
                  { "$set": { donatedate: req.body.donatedate}}(function(err, user){
                 var b = new User({
               username :req.params.username,
                 firstname :user.firstname,
                    lastname :user.lastname,
                  donatedate :user.donatedate
              })
                   if(err) {
                console.log(err);
                 res.status(500).send(err);
                   } else {
                   res.status(200).send(b);
                 }
                 }));
             }); 



via Poonam

No comments:

Post a Comment