orm-transaction

ORM Transactions

ORM Transaction Plugin

This plugin adds a transaction function for ORM.

Of course you need orm to use it. Other than that, no more dependencies.

npm install orm-transaction

Any driver supported by ORM is supported by this plugin.

db.transaction(function (errtransaction) {
// do your stuff 
transaction.commit(function (err) {
if (!err) {
console.log("success!");
}
});
});
var orm = require("orm");
var transaction = require("orm-transaction");
 
orm.connect("mysql://username:password@host/database", function (errdb) {
if (err) throw err;
 
db.use(transaction);
 
var Person = db.define("person", {
name      : String,
surname   : String,
age       : Number
});
 
db.transaction(function (errt) {
Person.find({ surname: "Doe" }).each(function (person) {
person.remove();
});
 
t.commit();
});
});