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

Commit 78c2475a by sdepold

moved getters to the top of the file

1 parent 0aaef45b
Showing with 20 additions and 20 deletions
var Utils = require("./utils") var Utils = require("./utils")
, Model = require("./model") , Model = require("./model")
, DataTypes = require("./data-types") , DataTypes = require("./data-types")
module.exports = (function() { module.exports = (function() {
...@@ -26,16 +26,6 @@ module.exports = (function() { ...@@ -26,16 +26,6 @@ module.exports = (function() {
this.validate = this.options.validate || {} this.validate = this.options.validate || {}
} }
ModelFactory.prototype.init = function(modelManager) {
this.modelManager = modelManager
addDefaultAttributes.call(this)
addOptionalClassMethods.call(this)
findAutoIncrementField.call(this)
return this
}
Object.defineProperty(ModelFactory.prototype, 'attributes', { Object.defineProperty(ModelFactory.prototype, 'attributes', {
get: function() { get: function() {
return this.QueryGenerator.attributesToSQL(this.rawAttributes) return this.QueryGenerator.attributesToSQL(this.rawAttributes)
...@@ -50,6 +40,24 @@ module.exports = (function() { ...@@ -50,6 +40,24 @@ module.exports = (function() {
get: function() { return this.QueryInterface.QueryGenerator } get: function() { return this.QueryInterface.QueryGenerator }
}) })
Object.defineProperty(ModelFactory.prototype, 'primaryKeyCount', {
get: function() { return Utils._.keys(this.primaryKeys).length }
})
Object.defineProperty(ModelFactory.prototype, 'hasPrimaryKeys', {
get: function() { return this.primaryKeyCount > 0 }
})
ModelFactory.prototype.init = function(modelManager) {
this.modelManager = modelManager
addDefaultAttributes.call(this)
addOptionalClassMethods.call(this)
findAutoIncrementField.call(this)
return this
}
ModelFactory.prototype.sync = function(options) { ModelFactory.prototype.sync = function(options) {
options = Utils.merge(options || {}, this.options) options = Utils.merge(options || {}, this.options)
...@@ -177,14 +185,6 @@ module.exports = (function() { ...@@ -177,14 +185,6 @@ module.exports = (function() {
return result return result
}) })
ModelFactory.prototype.__defineGetter__('primaryKeyCount', function() {
return Utils._.keys(this.primaryKeys).length
})
ModelFactory.prototype.__defineGetter__('hasPrimaryKeys', function() {
return this.primaryKeyCount > 0
})
// private // private
var query = function() { var query = function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!