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

Commit 9248772e by Sascha Depold

findOrCreate supports transactions

1 parent a1a7daa5
Showing with 22 additions and 1 deletions
...@@ -595,7 +595,8 @@ module.exports = (function() { ...@@ -595,7 +595,8 @@ module.exports = (function() {
params[attrname] = defaults[attrname] params[attrname] = defaults[attrname]
} }
self.create(params) self
.create(params, options)
.success(function (instance) { .success(function (instance) {
emitter.emit('success', instance, true) emitter.emit('success', instance, true)
}) })
......
...@@ -457,6 +457,26 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -457,6 +457,26 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
done() done()
}) })
}) })
it("supports transactions", function(done) {
var self = this
this.sequelize.transaction(function(t) {
self.User.findOrCreate({ username: 'Username' }, { data: 'some data' }, { transaction: t }).complete(function(err) {
expect(err).to.be.null
self.User.count().success(function(count) {
expect(count).to.equal(0)
t.commit().success(function() {
self.User.count().success(function(count) {
expect(count).to.equal(1)
done()
})
})
})
})
})
})
}) })
describe('create', function() { describe('create', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!