diff --git a/lib/abstract-class.js b/lib/abstract-class.js index 1d698447..6ad93bee 100644 --- a/lib/abstract-class.js +++ b/lib/abstract-class.js @@ -113,12 +113,11 @@ AbstractClass.prototype.whatTypeName = function (propName) { * @param data [optional] * @param callback(err, obj) */ -AbstractClass.create = function (data) { +AbstractClass.create = function (data, callback) { var modelName = this.modelName; - // define callback manually - var callback = arguments[arguments.length - 1]; - if (arguments.length == 0 || data === callback) { + if (typeof data === 'function') { + callback = data; data = {}; } diff --git a/test/common_test.js b/test/common_test.js index 009bca59..fa6e1b03 100644 --- a/test/common_test.js +++ b/test/common_test.js @@ -148,6 +148,20 @@ function testOrm(schema) { }); }); + it('should create object without callback', function (test) { + var uniqueTitle = 'Unique title ' + Date.now(); + Post.create({title: uniqueTitle}); + + setTimeout(delayedCallback, 100); + + function delayedCallback() { + Post.all({where: {title: uniqueTitle}}, function (err, posts) { + test.equal(posts.length, 1); + test.done(); + }); + } + }); + it('should save object', function (test) { var title = 'Initial title', title2 = 'Hello world', date = new Date;