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

Commit 0fa7608a by sdepold

refactored auto increment

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