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

Commit fe8283b1 by Elliot Foster

Move var definition to top of scope

1 parent 501baf72
...@@ -12,6 +12,7 @@ module.exports = (function() { ...@@ -12,6 +12,7 @@ module.exports = (function() {
HasManyDoubleLinked.prototype.injectGetter = function(options) { HasManyDoubleLinked.prototype.injectGetter = function(options) {
var self = this var self = this
, _options = options , _options = options
, smart
var customEventEmitter = new Utils.CustomEventEmitter(function() { var customEventEmitter = new Utils.CustomEventEmitter(function() {
var where = {} var where = {}
...@@ -62,7 +63,6 @@ module.exports = (function() { ...@@ -62,7 +63,6 @@ module.exports = (function() {
} }
if (options.where) { if (options.where) {
var smart
if (Array.isArray(options.where)) { if (Array.isArray(options.where)) {
smart = Utils.smartWhere([where, options.where], self.__factory.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.smartWhere([where, options.where], self.__factory.target.daoFactoryManager.sequelize.options.dialect)
smart = Utils.compileSmartWhere.call(self.__factory.target, smart, self.__factory.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.compileSmartWhere.call(self.__factory.target, smart, self.__factory.target.daoFactoryManager.sequelize.options.dialect)
......
...@@ -9,6 +9,7 @@ module.exports = (function() { ...@@ -9,6 +9,7 @@ module.exports = (function() {
HasManySingleLinked.prototype.injectGetter = function(options) { HasManySingleLinked.prototype.injectGetter = function(options) {
var self = this var self = this
, where = {} , where = {}
, smart
options = options || {} options = options || {}
var primaryKey = Object.keys(this.instance.rawAttributes).filter(function(k) { return self.instance.rawAttributes[k].primaryKey === true }) var primaryKey = Object.keys(this.instance.rawAttributes).filter(function(k) { return self.instance.rawAttributes[k].primaryKey === true })
...@@ -16,7 +17,7 @@ module.exports = (function() { ...@@ -16,7 +17,7 @@ module.exports = (function() {
where[this.__factory.identifier] = this.instance[primaryKey] where[this.__factory.identifier] = this.instance[primaryKey]
if (options.where) { if (options.where) {
var smart = Utils.smartWhere([where, options.where], this.__factory.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.smartWhere([where, options.where], this.__factory.target.daoFactoryManager.sequelize.options.dialect)
smart = Utils.compileSmartWhere.call(this.__factory.target, smart, this.__factory.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.compileSmartWhere.call(this.__factory.target, smart, this.__factory.target.daoFactoryManager.sequelize.options.dialect)
if (smart.length > 0) { if (smart.length > 0) {
options.where = smart options.where = smart
......
...@@ -45,6 +45,7 @@ module.exports = (function() { ...@@ -45,6 +45,7 @@ module.exports = (function() {
HasOne.prototype.injectGetter = function(obj) { HasOne.prototype.injectGetter = function(obj) {
var self = this var self = this
, smart
obj[this.accessors.get] = function(params) { obj[this.accessors.get] = function(params) {
var primaryKeys = Object.keys(this.daoFactory.primaryKeys) var primaryKeys = Object.keys(this.daoFactory.primaryKeys)
...@@ -62,7 +63,7 @@ module.exports = (function() { ...@@ -62,7 +63,7 @@ module.exports = (function() {
params = {where: where} params = {where: where}
} }
var smart = Utils.smartWhere(params.where || [], self.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.smartWhere(params.where || [], self.target.daoFactoryManager.sequelize.options.dialect)
smart = Utils.compileSmartWhere.call(self.target, smart, self.target.daoFactoryManager.sequelize.options.dialect) smart = Utils.compileSmartWhere.call(self.target, smart, self.target.daoFactoryManager.sequelize.options.dialect)
if (smart.length > 0) { if (smart.length > 0) {
params.where = smart params.where = smart
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!