I'm having some progress learning about Promises, but I don't understand why the knex behave like this in node.
I successfully receive a query and console.log it out, but when I run
node filename.js
The process doesn't quit and stay there after successfully print, like if the Promise still pending. Should not the knex.destroy() in the .finally statement end the Promise?
async function SELECT_ALL_P() {
const transaction = await knex.transaction()
return knex
.select('*')
.from('p')
.then(items => {
return console.log(items)
})
.catch(error => {
console.log(error)
})
.finally(function() {
knex.destroy()
})
}
SELECT_ALL_P()
I event tried like
.then(items => {
knex.destroy()
return console.log(items)
})
But it didn't worked also. I need to Ctrl+C in terminal to quit the node execution.