sqlite - NodeJS context issues -
i'm having issues writing socket (with http) sqlite (sqlite3) libary in node.js
https://gist.github.com/ryancopley/6004c3ce372e060bbf18
lines 68 75, have 4 attempts write. outside of db.each, works in context. within of it, crashes miserably. i'm not exclusively sure why, sense there conflict between 2 libraries
btw know concatenating sql statement bad :3
this because callback function in db.each
called asynchronously. means line 79: res.end()
called before res.write("found row!");
, triggering error.
i think want this:
db.serialize(function() { that.res.write("["); // works db.each("select * messages channel = '"+q.chan+"' , id > "+q.since+" order id", function(err, row) { res.write("found row!"); //does not work that.res.write("found row!"); //does not work console.log("found row!"); }); res.write("]");//works });
sqlite node.js http
No comments:
Post a Comment