was hab ich hier mit den promise falsch gemacht:
this.generateOneUpdate = function(email, data) {
var db = new sqlite3.Database(dbRef);
var statment = SQL_INSERT_MITARBEITER.replace(/\?name/g, "'" + data.name + "'");
db.run(statment);
function callback(user_id, m_id, data, dbLokal) {
var statmentLokal = SQL_INSERT_USER_MITARBEITER.replace(/\?user_id/g, user_id);
statmentLokal = statmentLokal.replace(/\?m_id/g, m_id);
dbLokal.run(statmentLokal);
statmentLokal = SQL_INSERT_SKILL.replace(/\?m_id/g, m_id);
statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
dbLokal.run(statmentLokal);
statmentLokal = SQL_REPLACE_SKILL.replace(/\?m_id/g, m_id);
statmentLokal = statmentLokal.replace(/\?skill/g, "'" + data.skill + "'");
statmentLokal = statmentLokal.replace(/\?subskill/g, "'" + data.subskill + "'");
statmentLokal = statmentLokal.replace(/\?nivau/g, "'" + data.nivau + "'");
dbLokal.run(statmentLokal);
}
statment = SQL_SELECT_USER_MITARBEITER_ID.replace(/\?email/g, "'" + email + "'");
statment = statment.replace(/\?name/g, "'" + data.name + "'");
var test = new Promise(function(resolve, reject) {db.all(statment, function(err, rows) {
resolve(rows);
})});
var pro = function () {
test.then(function (rows) {
var dbLokal = new sqlite3.Database(dbRef);
var last_index = rows.length - 1;
var user_id = rows[last_index].user_id;
var m_id = rows[last_index].mitarbeiter_id;
callback(user_id, m_id, data, dbLokal);
dbLokal.close();
})
.catch(function (error) {
console.log(error.message);
});
}
pro();
db.close();
}
ich krieg zwar in dem pro zeugs die daten, aber trotzdem bekomme ich zu 90% eine sqlite_busy: database is locked meldung...