I want to build an array of ids from a sqlite query using the node-sqlite3 library.
const sqlite3 = require('sqlite3')
const db = new sqlite3.Database('./db/database-name.db')
let ids = () => {
let sql = `select id from users;`
let result = []
db.each(sql, (err, row) => {
// console.log(row.id)
result.push(row.id)
})
return result
}
console.log(ids())
The console.log()
statement prints an empty array. What am I doing wrong?