我该如何在oriento中选择或更新多条记录?就像在waterline中我们可以做到的一样
offersModel.update({id:items_ids,status:INACTIVE},{status:ACTIVE})
但是,在水平面事务不可用。因此我想使用:
var db = offersModel.getDB();
var trans = db.begin();
trans.update('offers')
.set({status:INACTIVE})
.where({id:items_ids,status:ENM.SELLING_STATUS.ACTIVE})//.exec()
.then(function(offers){
if (offers.length != items_ids.length) {trans.rollback(); /* send error here*/}
else trans.commit();
})
谢谢。
.where({id:items_ids,status:ENM.SELLING_STATUS.ACTIVE}).exec()
,在.then(/*...*/)
前面是不需要.exec()
的。 - Dáriobegin() 然后更新项目,然后 **如果有任何项目丢失** 回滚() 否则提交()
。我该如何执行此事务? - 9mescalar()
函数,就像这个例子中一样。 - Alexis N-o