static add_binfile(id, data, cb) {
const sql = `UPDATE users SET binfile = ? WHERE id = ?`
db.run(sql, data.binfile, id, cb)
}
}
db.serialize(()=> {
const sql = `
CREATE TABLE IF NOT EXISTS users
(id INTEGER PRIMARY KEY, binfile BLOB)
`
db.run(sql)
})
Class.add_binfile(
id,
binfile,
(err) => {
if(err) return res.send('false')
res.format({
json: () => {
res.send('true')
}
})
In case you want to keep the callback as the 3rd parameter, you should set param to "[]"
// Directly in the function arguments.
db.run("UPDATE tbl SET name = ? WHERE id = ?", "bar", 2);
// As an array.
db.run("UPDATE tbl SET name = ? WHERE id = ?", [ "bar", 2 ]);
// As an object with named parameters.
db.run("UPDATE tbl SET name = $name WHERE id = $id", {
$id: 2,
$name: "bar"
});