Return instance of object when create
This commit is contained in:
parent
c1e3e78976
commit
2f048e79c0
|
@ -215,6 +215,8 @@ AbstractClass.create = function (data, callback) {
|
|||
}, data);
|
||||
}, data);
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
function stillConnecting(schema, obj, args) {
|
||||
|
|
|
@ -37,6 +37,16 @@ describe('manipulation', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return instance of object', function(done) {
|
||||
var person = Person.create(function(err, p) {
|
||||
p.id.should.eql(person.id);
|
||||
done();
|
||||
});
|
||||
should.exist(person);
|
||||
person.should.be.an.instanceOf(Person);
|
||||
should.not.exist(person.id);
|
||||
});
|
||||
|
||||
it('should work when called without callback', function(done) {
|
||||
Person.afterCreate = function(next) {
|
||||
this.should.be.an.instanceOf(Person);
|
||||
|
|
Loading…
Reference in New Issue