在oriento / orientjs中选择和更新多个记录,并在水线中进行事务 [英] SELECT and UPDATE multiple records in oriento / orientjs and transaction in waterline
本文介绍了在oriento / orientjs中选择和更新多个记录,并在水线中进行事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在oriento中选择或更新多个记录?像水线中一样,我们可以
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();
})
谢谢。
解决方案
试试这个
db.update(id).set({status:INACTIVE})。 scalar()
How can I select or update multiple records in oriento? Like in waterline we can
offersModel.update({id:items_ids,status:INACTIVE},{status:ACTIVE})
But in waterline transaction is not available. So I want to use :
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();
})
Thanks.
解决方案
Try this
db.update(id).set({status:INACTIVE}).scalar()
这篇关于在oriento / orientjs中选择和更新多个记录,并在水线中进行事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文