Allow to call create without callback
This commit is contained in:
parent
7f359c808e
commit
b237b7bd4c
|
@ -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 = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue