Answer the question
In order to leave comments, you need to log in
Node.js (Express.js + Sequelize.js ORM): Why is the query not getting results?
There is an application based on Express. Database - postgresql, ORM - Sequelize. This is a POST request handler in which I need to get the user from the database by username.
// /routes/login.js
router.post('/', function(req, res, next) {
models.User.findAll({
where: {
username:req.body.username
}
}).then(function(user) {
console.log(user);
});
res.render('login');
});
Executing (default): SELECT "id", "username", "password" FROM "Users" AS "User" WHERE "User"."username" = 'admin';
[]
SELECT id, username, password FROM Users WHERE username = 'admin';
router.post('/', function(req, res, next) {
models.User.findOne({
username: req.body.username
}).then(function(user) {
console.log(user);
});
res.render('login');
});
Executing (default): SELECT "id", "username", "password" FROM "Users" AS "User" LIMIT 1;
null
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question