所以基本上应该在我的 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");
}
}
由于某种原因,这些命令在运行SQL 命令each, get, all
时不起作用。SELECT * FROM FORWARDING
我究竟做错了什么?我不明白什么?
谢谢!