0
我想在單個交易中包裝多個函數。雖然它沒有拋出任何錯誤,但交易沒有被提交。Bookshelfjs:交易中的多個功能
下面是樣本片段。
function doSomething(ids){
bookshelf.transaction(function(trx){
if(someCondition){
new Service().save({ 'name': service.name },{transacting:trx}).then(function(){
doSomeDBUpdate1(ids,trx);
});
}else{
doSomeDBUpdate1(ids,trx);
}
})
}
function doSomeDBUpdate1(ids,trx){
new accounts({ id: accountId }).services().attach(serviceIds,{transacting:trx}).then(function(){
//do something
})
}