I'm trying to return a value from mysql using node and a query but i got an error that says nothing to me, i believe that is something related to my query but, i don't know what, can someone please help me? I've dig in a lot of places but didn't find anything that could help me. This is the code:
let queryIdBairro = "SELECT id FROM bairros ORDER BY id DESC LIMIT 1;"
conn.execSQLQuery(queryIdBairro, function(result, err) {
if(result){
bairro = result[0].id
let cadastraFrete = "INSERT INTO fretes_bairros (idempresa, idbairro, frete, status) VALUES (" + empresa + ", " + bairro + ", " + valor + ", " + 1 + ");"
conn.execSQLQuery(cadastraFrete, function(err, result) {
if(result){
console.log("[" + new Date() + "] " + "BAIRRO COM O ID " + bairro.id + "CADASTRADO COM SUCESSO")
resolve(bairro)
} else if(err){
console.log("DEU RUIM PARA SALVAR O FRETE AMIGUINHO... [" + new Date() + "] " + err)
}
})
} else if(err){
console.log("DEU RUIM NA PRIMEIRA BUSCA DO NOVO BAIRRO AMIGUINHO... [" + new Date() + "] " + err)
}
})
In the console i got this:
[Mon Jun 29 2020 13:50:31 GMT-0300 (GMT-03:00)] [object Object]
I'm pretty new on node and have no idea about this error or how to fix it exactly. Any help will be very appreciated.
Thanks in advance.