https://github.com/dresende/node-orm-transaction
ORM Transaction Plugin
https://github.com/dresende/node-orm-transaction
Last synced: 10 months ago
JSON representation
ORM Transaction Plugin
- Host: GitHub
- URL: https://github.com/dresende/node-orm-transaction
- Owner: dresende
- Created: 2013-06-06T22:45:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T03:59:11.000Z (over 7 years ago)
- Last Synced: 2025-03-17T19:52:12.495Z (10 months ago)
- Language: JavaScript
- Homepage: http://dresende.github.io/node-orm-transaction/
- Size: 129 KB
- Stars: 22
- Watchers: 6
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## ORM Transaction Plugin [](https://npmjs.org/package/orm-transaction)
This plugin adds a transaction function for [ORM](http://dresende.github.io/node-orm2).
## Dependencies
Of course you need `orm` to use it. Other than that, no more dependencies.
## Install
```sh
npm install orm-transaction
```
## DBMS Support
Any driver supported by ORM is supported by this plugin.
## Usage
```js
db.transaction(function (err, transaction) {
// do your stuff
transaction.commit(function (err) {
if (!err) {
console.log("success!");
}
});
});
```
## Example
```js
var orm = require("orm");
var transaction = require("orm-transaction");
orm.connect("mysql://username:password@host/database", function (err, db) {
if (err) throw err;
db.use(transaction);
var Person = db.define("person", {
name : String,
surname : String,
age : Number
});
db.transaction(function (err, t) {
Person.find({ surname: "Doe" }).each(function (person) {
person.remove();
});
t.commit(function (err) {
if (!err) {
console.log("success!");
}
});
});
});
```