2
I am using Mongodb and returns me all the right data but when I want to add a new Key simply 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 validation the result is this, in both the if and the other.
{ _id: 59fa1a69349c9f382f0a2892,
nome: 'qqqqqqq',
telefone: '189789469',
curso: 'eeeeee',
email: 'teste',
senha: 2651
codigo: 2,
__v: 0 }
And where is the code for creation? You can post it?
– Good Bye Blue sky
You are referring to the bank creation code ?
– Erick Zanetti
Exact, the code that generates the error (failure to create the key), unless I misunderstood your question
– Good Bye Blue sky
It shows no error code, I try to assign the key status and in the console.log I get the key status does not exist.
– Erick Zanetti
If you do
var usuario = Object.merge({}, logins[0]);
already works?– Sergio