SELECT and UPDATE multiple records in oriento / orientjs and transaction in waterline

做~自己de王妃 提交于 2019-12-22 01:49:25

问题


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.


回答1:


Try this

db.update(id).set({status:INACTIVE}).scalar()




回答2:


Have you tried following?

db.update(id).set({status:INACTIVE}).scalar()


来源:https://stackoverflow.com/questions/29446477/select-and-update-multiple-records-in-oriento-orientjs-and-transaction-in-wate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!