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

Commit c4b38570 by Brandon Skari

Add default value of 1 to decrement to match increment

1 parent cfbec56a
Showing with 28 additions and 0 deletions
......@@ -391,6 +391,10 @@ module.exports = (function() {
});
}
if (count === undefined) {
count = 1;
}
return this.increment(fields, 0 - count);
}
......
......@@ -290,6 +290,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
it('with single field and no value', function(done) {
var self = this
this.User.find(1).complete(function(err, user1) {
user1.increment('aNumber').complete(function() {
self.User.find(1).complete(function(err, user2) {
expect(user2.aNumber).to.be.equal(1)
done()
})
})
})
})
it('should still work right with other concurrent updates', function(done) {
var self = this
this.User.find(1).complete(function (err, user1) {
......@@ -388,6 +400,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
it('with single field and no value', function(done) {
var self = this
this.User.find(1).complete(function(err, user1) {
user1.decrement('aNumber').complete(function() {
self.User.find(1).complete(function(err, user2) {
expect(user2.aNumber).to.be.equal(-1)
done()
})
})
})
})
it('should still work right with other concurrent updates', function(done) {
var self = this
this.User.find(1).complete(function(err, user1) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!