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

Commit 41812ff7 by Overlook Motel

code tidying

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