我在序列化 nodeJS 中的几个函数时遇到问题。我想要做的是创建一个临时视图,读取它,然后为 ft 数组中的每个元素删除它。这是我的代码。我在 NodeJS 中使用以下函数。Db 是一个用于 node 的 sqlite3 插件。
function(){
ft.forEach(function(fti){
var view="create temporary view ..."+fti;
db.exec(view,aftaView)
console.log("created View "+fti);
});
};
function aftaView(err){
if (err) console.log(err+" K ");
participantID.forEach(function(prt){
Obj.forEach(function(bj){
console.log("Object: "+bj);
//perform second query here
db.all("select ...", {$pID:prt,$obj:bj}, function(err,rows){
if (err) throw err;
rows.forEach(function (row) {
//console.log(row);
});
//perform third function here, in readiness for second iterarion of the very // first loop
db.run("drop view Kemp");
});
});
});
};
这是控制台输出:
created View 1
created View 2
created View 3
created View 4
created View 5
created View 6
//fails
Error: SQLITE_ERROR: view already exists
我显然需要确保第二个函数为第一个循环中的每个项目运行,我只是不知道如何。任何帮助将不胜感激