【发布时间】:2019-12-29 00:47:07
【问题描述】:
我需要知道在 nodejs 中在 mysql 上使用 xdevapi 插入语句后的主键 auto_increment 值。
我的代码是:
sqlQueries.getDBConnection(con =>
(function inner(con) {
var query = "INSERT INTO users (name) VALUES ('test')";
var executeSql = con.sql(query).execute();
con.close();
con.done();
return executeSql;
}(con)).then(function (res) {
/***********/
doSomethingWithTheId(id);
/***********/
con.close();
con.done();
}).catch(e => {
cl(e);
})
);
但我不明白如何获取 id 以在 doSomethingWIthTheId() 函数中使用它。
我尝试 console.log(result) 但似乎我得到了一系列方法,但我不知道如何获得我需要的信息。
【问题讨论】: