【发布时间】:2017-02-04 17:13:22
【问题描述】:
所以基本上应该在我的 SQL 命令完成后运行回调,但由于某种原因,回调永远不会执行。
这是我目前拥有的代码:
create : function() {
var hit = false;
this.db.serialize(function() {
this.run("CREATE TABLE if not exists messages (phone_from CHAR(20) NOT NULL, phone_to CHAR(20) NOT NULL, message TEXT)");
this.run("CREATE TABLE if not exists forwarding (phone_1 CHAR(20) NOT NULL, phone_2 CHAR(20) NOT NULL, phone_bind CHAR(20) NOT NULL)");
this.get("SELECT * FROM FORWARDING;", function(err, row) {
hit = true; //<--- Why is this never being hit?
});
});
if (hit) {
this.insert_forwarding("+18001231234","+18003214321","+18005432322");
console.log("Inserted initial forwarding address");
}
}
由于某种原因,each, get, all 命令在运行SELECT * FROM FORWARDING SQL 命令时不起作用。
我做错了什么?什么不明白?
谢谢!
【问题讨论】:
标签: node.js sqlite node-sqlite3