Return instance of object when create

This commit is contained in:
Anatoliy Chakkaev 2013-03-30 21:06:09 +04:00
parent c1e3e78976
commit 2f048e79c0
2 changed files with 12 additions and 0 deletions

View File

@ -215,6 +215,8 @@ AbstractClass.create = function (data, callback) {
}, data);
}, data);
}
return obj;
};
function stillConnecting(schema, obj, args) {

View File

@ -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);