不要怂,就是干,撸起袖子干!

Commit ef558774 by Sascha Depold

commit and rollback transactions

1 parent ee3d5905
Showing with 12 additions and 3 deletions
var Utils = require('./utils')
, util = require('util')
var Transaction = module.exports = function(options) {
var Transaction = module.exports = function(sequelize, options) {
this.sequelize = sequelize
this.options = options || {}
this.id = Utils.generateUUID()
}
......@@ -9,10 +10,18 @@ var Transaction = module.exports = function(options) {
util.inherits(Transaction, Utils.CustomEventEmitter)
Transaction.prototype.commit = function() {
this.emit('success')
this
.sequelize
.getQueryInterface()
.commitTransaction({ transaction: this })
.proxy(this)
}
Transaction.prototype.rollback = function() {
this.emit('success')
this
.sequelize
.getQueryInterface()
.rollbackTransaction({ transaction: this })
.proxy(this)
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!