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

Commit 0fa7608a by sdepold

refactored auto increment

1 parent 6436c021
Showing with 10 additions and 10 deletions
......@@ -110,7 +110,7 @@ module.exports = (function() {
// options is not a hash but an id
if(typeof options == 'number')
options = {where: options}
options = { where: options }
else if (Utils.argsArePrimaryKeys(arguments, this.primaryKeys)) {
var where = {}
, self = this
......@@ -120,7 +120,7 @@ module.exports = (function() {
where[key] = arg
})
options = {where: where}
options = { where: where }
}
options.limit = 1
......@@ -228,16 +228,16 @@ module.exports = (function() {
}
var findAutoIncrementField = function() {
var self = this
var self = this
, fields = this.QueryGenerator.findAutoIncrementField(this)
this.autoIncrementField = null
Utils._.map(this.attributes, function(definition, name) {
if (definition && (definition.indexOf('auto_increment') > -1)) {
if (self.autoIncrementField)
throw new Error('Invalid model definition. Only one autoincrement field allowed.')
else
self.autoIncrementField = name
}
fields.forEach(function(field) {
if(self.autoIncrementField)
throw new Error('Invalid model definition. Only one autoincrement field allowed.')
else
self.autoIncrementField = field
})
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!