Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3672

How to check whether update succeeded in node.js and sqlite3 ?

$
0
0

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.


Viewing all articles
Browse latest Browse all 3672

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>