Merge branch 'master' into juggler-tidyup
Conflicts: lib/model.js
This commit is contained in:
commit
24d87976e8
|
@ -226,7 +226,7 @@ ModelBaseClass.prototype.toObject = function (onlySchema) {
|
|||
if (schemaLess) {
|
||||
Object.keys(self.__data).forEach(function (propertyName) {
|
||||
if (!data.hasOwnProperty(propertyName)) {
|
||||
var val = self.__data[propertyName];
|
||||
var val = self.hasOwnProperty(propertyName) ? self[propertyName] : self.__data[propertyName];
|
||||
if(val !== undefined && val!== null && val.toObject) {
|
||||
data[propertyName] = val.toObject(!schemaLess);
|
||||
} else {
|
||||
|
@ -290,4 +290,4 @@ ModelBaseClass.mixin = function(anotherClass, options) {
|
|||
};
|
||||
|
||||
jutil.mixin(ModelBaseClass, Hookable);
|
||||
jutil.mixin(ModelBaseClass, validations.Validatable);
|
||||
jutil.mixin(ModelBaseClass, validations.Validatable);
|
||||
|
|
|
@ -369,6 +369,21 @@ describe('DataSource define model', function () {
|
|||
done(null, User);
|
||||
});
|
||||
|
||||
|
||||
it('should change the property value for save if strict=false', function (done) {
|
||||
var ds = new DataSource('memory');// define models
|
||||
var Post = ds.define('Post');
|
||||
|
||||
Post.create({price: 900}, function(err, post) {
|
||||
assert.equal(post.price, 900);
|
||||
post.price = 1000;
|
||||
post.save(function(err, result) {
|
||||
assert.equal(1000, result.price);
|
||||
done(err, result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue