Fix instanceof checking
This commit is contained in:
parent
8b4da9e5e9
commit
c8322eea31
|
@ -161,10 +161,10 @@ AbstractClass.create = function (data, callback) {
|
|||
|
||||
var obj = null;
|
||||
// if we come from save
|
||||
if (data instanceof AbstractClass && !data.id) {
|
||||
if (data instanceof this && !data.id) {
|
||||
obj = data;
|
||||
data = obj.toObject(true);
|
||||
this.prototype._initProperties.call(obj, data, false);
|
||||
obj._initProperties(data, false);
|
||||
create();
|
||||
} else {
|
||||
obj = new this(data);
|
||||
|
@ -188,6 +188,8 @@ AbstractClass.create = function (data, callback) {
|
|||
|
||||
this._adapter().create(modelName, this.constructor._forDB(data), function (err, id) {
|
||||
if (id) {
|
||||
obj.__data.id = id;
|
||||
obj.__dataWas.id = id;
|
||||
defineReadonlyProp(obj, 'id', id);
|
||||
}
|
||||
done.call(this, function () {
|
||||
|
|
|
@ -855,7 +855,6 @@ function testOrm(schema) {
|
|||
User.find(user.id, function (err, user) {
|
||||
test.ok(user !== u);
|
||||
test.equal(user.passwd, 'qwertysalt');
|
||||
console.log(user.id);
|
||||
User.all({where: {passwd: 'qwertysalt'}}, function (err, users) {
|
||||
test.ok(users[0] !== user);
|
||||
test.equal(users[0].passwd, 'qwertysalt');
|
||||
|
|
Loading…
Reference in New Issue