1
我在节点执行这个膝盖查询:节点Knex插入不执行
return Knex.transaction(function (tx) {
debug("Inserting new story record");
return tx.insert({
'projectId':projectId,
'title': title,
'story': text,
'points': 0,
'storyNumber': Knex('story').max('storyNumber').where('projectId', projectId)
}, 'id')
.into('story')
.then(function (id) {
debug("Returning story for %s", id);
return getStory(id);
})
})
但“则()函数永远不会被调用。有人知道为什么
我一直在阅读所有的knex doco,看起来我做的一切都是正确的。该命令的调试如下所示:
crux:db Inserting new story record +4ms
{ method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings: [ 0, 2, 'test', 2, 'title' ],
__knexQueryUid: 'aa5ff1d3-eff0-4687-864b-772c26e1aebd',
sql: 'insert into `story` (`points`, `projectId`, `story`, `storyNumber`, `title`) values (?, ?, ?, (select max(`storyNumber`) from `story` where `projectId` = ?), ?)' }
所以这对我来说都很好。永远不要执行。