function bathExecuteSql(sqlArray) {
//开启事务
beginTransaction();
//使用Promise异步调用,避免其他函数阻塞
new Promise((resolve, reject) => {
for (var i = 0; i < sqlArray.length; i++) {
//如果出错,则终止执行,回调reject函数
if (!executeSql(sqlArray[i])) {
reject(false)
}
}
//执行完成
resolve(true);
}).then(
(res) => {
//执行完成,提交事务
commitTransaction();
return res;
},
(err) => {
//出错,回滚事务
rollbackTransaction();
return err;
}
)
}

cxjfun
- 发布:2020-10-25 15:17
- 更新:2021-01-28 13:24
- 阅读:3009
1 个评论
要回复文章请先登录或注册
黄Adai