I'm looking at this tutorial, which has a library called aa-sqlite in order to replace Promises() syntax with async-await.
I'm not seeing aa-sqlite on npm. Is there another, updated syntax for async await sqlite?
Here is what I'm trying with the standard sqlite library:
const sqlite3 = require('sqlite3').verbose();
let db = new sqlite3.Database("tmp.db")
async function myfunc(db) {
let sql = "SELECT id id FROM TABLE LIMIT 2"
let res1 = await db.run(sql)
console.log(res1)
for (row of res1) {
console.log(row);
}
But this yields
TypeError: res1 is not iterable
I am not expecting res1 to be an object, but instead an iterator of results. How can I async/await the results of a db.run query in ES7/ES8?
console.log(res1)log?for ..ofwith objects. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…sqlite3does not supportpromiseorasync/awaitsyntax. In ES6, you can wrap callback based functions with Promise, which are essentially a return value with state (pending, resolved, rejected).