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

Databasesails.jsOrientdbWaterlineSails Orientdb

Database Problem Overview


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.

Database Solutions


Solution 1 - Database

Try this

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

Solution 2 - Database

Have you tried following?

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question9meView Question on Stackoverflow
Solution 1 - DatabaseSridhar BodakuntiView Answer on Stackoverflow
Solution 2 - DatabasePrashantView Answer on Stackoverflow