Could anyone give me any advice on how to check whether an update statement has succeeded when using node.js and the sqlite3 package installed from npm install sqlite3 (https://github.com/developmentseed/node-sqlite3/wiki/API)
To perform an update, I'm doing the following:
var id = req.params.id; var thing = req.body; stmt = db.prepare("UPDATE FOO set name=?, year=? where id=?"); stmt.bind(thing.name, thing.year, id); stmt.run(function(err, result) { if (err) { res.send(JSON.stringify(err)); res.send({'error':'An error has occurred'}); } else { if (result) { console.log('Success: '+ JSON.stringify(result)); } res.send(JSON.stringify(wine)); } });
However, result is never defined.
If I change stmt.run() to be stmt.all(), I get a result, but it seems to be empty - printing it to the console shows nothing.