Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 264
9me Avatar asked Apr 04 '15 12:04

9me


1 Answers

Try this

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

like image 83
Sridhar Bodakunti Avatar answered Nov 02 '22 05:11

Sridhar Bodakunti