不要怂,就是干,撸起袖子干!

Commit 41812ff7 by Overlook Motel

code tidying

1 parent ba6f9c36
......@@ -452,7 +452,7 @@ module.exports = (function() {
if (Object(association.through) === association.through) {
// Create the related model instance
return association.target.create(values, fieldsOrOptions).then(function(newAssociatedObject) {
return instance[association.accessors.add](newAssociatedObject, options).return (newAssociatedObject);
return instance[association.accessors.add](newAssociatedObject, options).return(newAssociatedObject);
});
} else {
values[association.identifier] = instance.get(association.source.primaryKeyAttribute);
......
......@@ -174,7 +174,7 @@ InstanceValidator.prototype.hookValidate = function() {
});
}).then(function() {
return self.modelInstance.Model.runHooks('afterValidate', self.modelInstance);
}).return (self.modelInstance);
}).return(self.modelInstance);
};
/**
......@@ -223,7 +223,7 @@ InstanceValidator.prototype._customValidators = function() {
var valprom = self._invokeCustomValidator(validator, validatorType)
// errors are handled in settling, stub this
.catch (noop);
.catch(noop);
validators.push(valprom);
});
......@@ -302,10 +302,10 @@ InstanceValidator.prototype._invokeCustomValidator = Promise.method(function(val
validatorFunction = Promise.promisify(validator.bind(this.modelInstance));
}
return validatorFunction()
.catch (this._pushError.bind(this, false, errorKey));
.catch(this._pushError.bind(this, false, errorKey));
} else {
return Promise.try(validator.bind(this.modelInstance, invokeArgs))
.catch (this._pushError.bind(this, false, errorKey));
.catch(this._pushError.bind(this, false, errorKey));
}
});
......
......@@ -489,7 +489,8 @@ module.exports = (function() {
&& !!self.Model.rawAttributes[updatedAtAttr].defaultValue
)
? self.Model.rawAttributes[updatedAtAttr].defaultValue
: Utils.now(self.sequelize.options.dialect));
: Utils.now(self.sequelize.options.dialect)
);
}
if (self.isNewRecord && createdAtAttr && !values[createdAtAttr]) {
......@@ -499,8 +500,9 @@ module.exports = (function() {
&& !!self.Model.rawAttributes[createdAtAttr].defaultValue
)
? self.Model.rawAttributes[createdAtAttr].defaultValue
: Utils.now(self.sequelize.options.dialect));
}
: Utils.now(self.sequelize.options.dialect)
);
}
var query = null
, args = []
......@@ -605,7 +607,7 @@ module.exports = (function() {
include: this.options.include || null
}, options).then(function(reload) {
self.set(reload.dataValues, {raw: true, reset: true});
}).return (self);
}).return(self);
};
/*
......
......@@ -388,10 +388,10 @@ module.exports = (function() {
if (options.force) {
return self.drop(options).then(function() {
return doQuery().return (self);
return doQuery().return(self);
});
} else {
return doQuery().return (this);
return doQuery().return(this);
}
};
......@@ -1119,16 +1119,14 @@ module.exports = (function() {
Utils.validateParameter(options, 'undefined', { deprecated: Object, optional: true, index: 3, method: 'Model#bulkCreate' });
if (!records.length) {
return new Promise(function(resolve) {
resolve([]);
});
return Promise.resolve([]);
}
options = Utils._.extend({
validate: false,
hooks: false,
ignoreDuplicates: false
}, options ||  {});
}, options || {});
if (fieldsOrOptions instanceof Array) {
options.fields = fieldsOrOptions;
......
......@@ -594,7 +594,7 @@ module.exports = (function() {
* @return {Promise}
*/
Sequelize.prototype.authenticate = function() {
return this.query('SELECT 1+1 AS result', null, { raw: true, plain: true }).return ().catch (function(err) {
return this.query('SELECT 1+1 AS result', null, { raw: true, plain: true }).return().catch(function(err) {
throw new Error(err);
});
};
......
......@@ -5301,7 +5301,6 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
fn()
})
this.User.bulkCreate([
{aNumber: 1}, {aNumber: 1}, {aNumber: 1}
]).success(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!