-
-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem when promisify run
#658
Comments
In Tofino we manually promisify a bunch of the less-sane https://github.com/mozilla/tofino/blob/master/app/services/user-agent-service/sqlite.js#L109 |
@rnewman Thanks. For others coming in late the link in the above comment is dead and the capability is now available as promise-sqlite. |
We'd happily review a PR that implements lastID in the results object, but for now, you can use a library like pify that accepts a |
@tmcw can I get some additional information on using var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');
var pify = require('pify');
db.serialize(function() {
db.run("CREATE TABLE lorem (info TEXT)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) { stmt.run("Ipsum " + i); }
stmt.finalize();
db.get("SELECT * FROM lorem", function(err, row) { console.log('err', err, 'row', row); });
pify(db.get, {multiArgs: true})("SELECT * FROM lorem")
.then(x => console.log('promise', x))
.catch(e => console.log('promise error', e));
});
db.close(); the callback works but promisified Has something changed in the last couple of years in sqlite3 that prevents |
Sorry for bugging you all. I realized it was a
work as expected. (And if this |
Currently the callback argument for
run
only accept one parameter, namelyerr
, andlastID
andchanges
can be get fromthis
inside the callback. When promisify using tools like bluebird, things likelastID
are lost. It would be nice to have those passed to the callback as the second argument, and this is also a nodejs convention I believe.The text was updated successfully, but these errors were encountered: