db.run("INSERT INTO test VALUES (?)", [testVal], function(err) {
console.log(err);
console.log(this.lastId);
console.log(this);
})
错误 - 返回空值, this.lastID - 返回未定义, this - 返回 Window 对象
如何获取最后插入的标识符?
最佳答案
实际上你必须使用 lastID(大写 D)。
db.run("INSERT INTO foo ...", function(err) {
// err is null if insertion was successful
console.warn("inserted id:", this.**lastID**);
});
关于javascript - Node.js 中的 sqlite3 不从 INSERT 回调返回 lastID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39574938/