【发布时间】:2019-09-26 15:51:40
【问题描述】:
我们在 nodejs 中使用 knexjs。我们正在尝试将事务与原始查询一起使用,但它没有按预期工作。当抛出错误时,会调用回滚函数,但在数据库中我可以看到数据
const trx = await knex.transaction();
await trx.schema.createTable("test", function(table) {
table.increments();
table.string("name");
});
await trx("test").insert({ name: "foo1" });
await trx("test").insert({ name: "foo2" });
await trx.rollback();
是否可以将事务与原始查询一起使用?
【问题讨论】:
-
您可以在事务中进行类似的查询吗?错误信息是什么?
标签: knex.js