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

Commit 856a2150 by Jan Aagaard Meier

enable single field instead of array

1 parent f89d88d2
Showing with 33 additions and 2 deletions
...@@ -241,6 +241,7 @@ module.exports = (function() { ...@@ -241,6 +241,7 @@ module.exports = (function() {
var identifier = this.__options.hasPrimaryKeys ? this.primaryKeyValues : this.id, var identifier = this.__options.hasPrimaryKeys ? this.primaryKeyValues : this.id,
values = {} values = {}
if (!Utils._.isArray(fields)) fields = [fields];
if (count === undefined) count = 1; if (count === undefined) count = 1;
Utils._.each(fields, function (field) { Utils._.each(fields, function (field) {
......
...@@ -40,7 +40,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() { ...@@ -40,7 +40,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
this.User.create({ id: 1, aNumber: 0 }).done(done) this.User.create({ id: 1, aNumber: 0 }).done(done)
}); });
it('', function (done) { it('with array', function (done) {
var self = this; var self = this;
// Select something // Select something
...@@ -55,6 +55,21 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() { ...@@ -55,6 +55,21 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
}); });
}); });
it('with single field', function (done) {
var self = this;
// Select something
this.User.find(1).done(function (err, user1) {
user1.increment('aNumber', 2).done(function (err, user2) {
self.User.find(1).done(function (err, user3) {
expect(user3.aNumber).toBe(user1.aNumber + 2);
done();
});
});
});
});
it('should still work right with other concurrent updates', function (done) { it('should still work right with other concurrent updates', function (done) {
var self = this; var self = this;
// Select something // Select something
...@@ -99,7 +114,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() { ...@@ -99,7 +114,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
this.User.create({ id: 1, aNumber: 0 }).done(done) this.User.create({ id: 1, aNumber: 0 }).done(done)
}); });
it('', function (done) { it('with array', function (done) {
var self = this; var self = this;
// Select something // Select something
...@@ -114,6 +129,21 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() { ...@@ -114,6 +129,21 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
}); });
}); });
it('with single field', function (done) {
var self = this;
// Select something
this.User.find(1).done(function (err, user1) {
user1.decrement('aNumber', 2).done(function (err, user2) {
self.User.find(1).done(function (err, user3) {
expect(user3.aNumber).toBe(user1.aNumber - 2);
done();
});
});
});
});
it('should still work right with other concurrent updates', function (done) { it('should still work right with other concurrent updates', function (done) {
var self = this; var self = this;
// Select something // Select something
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!