Working with node and sqlite I have the following which queries a table and returns a result:
async function select_from_table(tablename, limit) {
let arr = [];
let sql = `SELECT id FROM ${tablename} WHERE Type='Real' LIMIT ${limit}`;
await db.each(sql, function (err, row) {
console.log(row.id);
arr.push(row.id);
});
return await arr;
}
This returns a promise and appears to work when I run it with;
return select_from_table('myData', 5);
however, when I try to run it in a different file after importing it:
const sqlite = require('./sqlite');
const sel = sqlite.select_from_table;
const myTestUrls = helpers.detailUrls(return sel('myData',3););
I get the error mentioned above in title. How can I fix this?
edit:
const myTestUrls = helpers.detailUrls(await sel('myData',3));
^^^^^
SyntaxError: missing ) after argument list