Monday, 29 May 2017

Find and render user from mongodb

A little background. I am sending a post with the username. About what he came to me is displayed in the log.

console.log(req.body.username); // 'username'

How do I use mongodb to find and render a user with a username from the post?

For example, the sample and render of all users looks like this, but I still do not understand how to get the one I need

exports.profile = function(req, res, next){

User.find(function(err,users){
    if(err) return next(err);
    res.render('users/profile',{  users:users });
});}



via Princeair

No comments:

Post a Comment