I'm using MongoDB and it returns me all the right data but when I want to add a new key it just does not create.
exports.validaLogin = function(req, res) {
login.find({
"nome": req.query.usuario
},function (err, logins) {
if(err) {
return handleError(res, err);
}
var usuario = logins[0]
if(usuario.senha == req.query.senha){
usuario.status = 1
console.log("aqui")
} else {
console.log("nao")
usuario.status = 0
}
console.log(usuario)
return res.status(200).json(usuario);
}); };
In my console.log after the validation the result is this, both in the if and in the other.
{ _id: 59fa1a69349c9f382f0a2892,
nome: 'qqqqqqq',
telefone: '189789469',
curso: 'eeeeee',
email: 'teste',
senha: 2651
codigo: 2,
__v: 0 }