Waterline Transaction through sails-orientdb

2019-08-11 01:03发布

问题:

I'm using transaction in the following code, can I enhance this code furthermore?

var db = itemsModel.getDB();
var trans = db.begin();
trans.update('items')
     .set({status:UNAVAILABLE})
     .where({id:items_ids_list,status:AVAILABLE}).exec()
     .then(function(items){ 
         if (items.length != items_ids_list.length) {
             trans.rollback(); /* send error here*/
         } else trans.commit();
     });