2
在pg-promise
我有,我需要触发内幕交易如果需要的话,可以回滚不会导致调用交易的情况时,错误回滚:pg-promise有没有办法触发不会影响外部事务的内部事务?
var db = pgp()(connection);
db.task(function (tk){
tk.method(/* Logic used to decide if I need to continue */)
.then(function(data){
if (!data) return;
tk.tx(function*(tx){
// Somewhere in here I need to fire another transaction that I don't care if it fails
// but I need things to roll back inside of it should it fail
// without cause this tx to fail
})
})
})
我什么都如果内部事务失败,而不是内部事务回滚,并且外部事务继续执行后面的逻辑,那么到目前为止尝试的操作只是导致外部事务(tx
)回滚。如果子事务失败,是否有可靠的方法导致内部事务不会导致tx
回滚?
作为补充:当我尝试使用Bluebird
Promise.some(tx1, tx2)
作为失败原因tx
回滚而其他tx#失败并回滚时也失败。内pg-promise
我很好奇,如果是因为我们被锁定到pg-promise的旧版本。我将检查github上的提交历史记录以及可能的解决方案。 –
@RobertMennell可能是因为你在混合使用ES6生成器,那些可能会很棘手,容易犯错误,你应该或不应该使用'yield';) –
谢谢指出!没有想到这一点,但对每个追随我的人都会有所帮助 –