Closed jcwren closed 9 years ago
It seems not to be a standard async with a callback(err,data). You can try standardizing it: https://github.com/luciotato/waitfor#notes-on-non-standard-callbacks-eg-connectionquery-from-mysql
try this:
db.prototype.prep = function(sql, stdCallback){
var stmt = this.prepare(sql, function(err){
return stdCallback(err, stmt);
});
}
var stmt = wait.forMethod (db, 'prep', "INSERT OR REPLACE INTO foo (a,b,c) VALUES (?,?,?)");
Excellent. While it's technically not necessary, it does mean that I can have consistency, which makes for better readability. Thank you.
I'm using sqlite3's database#prepare statement, and neither wait.for() or wait.forMethod() returns correct results.
From the documentation:
This (normal form) works:
No error occurs, and the statement is later used in a
wait.forMethod (stmt, 'run', records);
.With wait.for():
throws an error: TypeError: Database object expected
With wait.forMethod():
returns undefined.
This well could be a misunderstanding on my part, but shouldn't I be able to use prepare with one or the other wait() calls? I use
wait.forMethod (db, 'run', 'BEGIN TRANSACTION');
without issues.And thank you for an excellent package. It really turned some horribly nested callbacks into something readable.