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

Commit 01c1af36 by Mick Hansen Committed by Jan Aagaard Meier

picking

1 parent 77b72e0a
...@@ -103,7 +103,7 @@ module.exports = (function() { ...@@ -103,7 +103,7 @@ module.exports = (function() {
}.bind(this)) }.bind(this))
} }
this.daoFactoryManager.sequelize._metric('Model.findAll', tk.time() - start); this.daoFactoryManager.sequelize._metric('DAOFactory.findAll', tk.time() - start);
return this.QueryInterface.select(this, this.tableName, options) return this.QueryInterface.select(this, this.tableName, options)
} }
...@@ -150,7 +150,7 @@ module.exports = (function() { ...@@ -150,7 +150,7 @@ module.exports = (function() {
options.limit = 1 options.limit = 1
this.daoFactoryManager.sequelize._metric('Model.find', tk.time() - start); this.daoFactoryManager.sequelize._metric('DAOFactory.find', tk.time() - start);
return this.QueryInterface.select(this, this.tableName, options, { plain: true }) return this.QueryInterface.select(this, this.tableName, options, { plain: true })
} }
...@@ -180,8 +180,10 @@ module.exports = (function() { ...@@ -180,8 +180,10 @@ module.exports = (function() {
DAOFactory.prototype.build = function(values, options) { DAOFactory.prototype.build = function(values, options) {
var start = tk.time(); var start = tk.time();
var instance = new DAO(values, Utils._.extend(this.options, this.attributes, { hasPrimaryKeys: this.hasPrimaryKeys })) var instance = new DAO(values, Utils._.extend(this.options, { hasPrimaryKeys: this.hasPrimaryKeys, factory: this }))
, self = this , self = this
this.daoFactoryManager.sequelize._metric('DAOFactory.newDAO', tk.time() - start);
options = options || {} options = options || {}
instance.__factory = this instance.__factory = this
...@@ -218,7 +220,7 @@ module.exports = (function() { ...@@ -218,7 +220,7 @@ module.exports = (function() {
instance.isNewRecord = options.hasOwnProperty('isNewRecord') ? options.isNewRecord : true instance.isNewRecord = options.hasOwnProperty('isNewRecord') ? options.isNewRecord : true
instance.selectedValues = values instance.selectedValues = values
this.daoFactoryManager.sequelize._metric('Model.build', tk.time() - start); this.daoFactoryManager.sequelize._metric('DAOFactory.build', tk.time() - start);
return instance return instance
} }
......
...@@ -2,11 +2,14 @@ var Utils = require("./utils") ...@@ -2,11 +2,14 @@ var Utils = require("./utils")
, Mixin = require("./associations/mixin") , Mixin = require("./associations/mixin")
, Validator = require("validator") , Validator = require("validator")
var tk = require('timekit');
module.exports = (function() { module.exports = (function() {
var DAO = function(values, options) { var DAO = function(values, options) {
var start = tk.time();
this.attributes = [] this.attributes = []
this.validators = {} // holds validation settings for each attribute this.validators = {} // holds validation settings for each attribute
this.__factory = null // will be set in DAO.build this.__factory = options.factory || null // will be set by DAO.build if not present
this.__options = Utils._.extend({ this.__options = Utils._.extend({
underscored: false, underscored: false,
hasPrimaryKeys: false, hasPrimaryKeys: false,
...@@ -15,6 +18,8 @@ module.exports = (function() { ...@@ -15,6 +18,8 @@ module.exports = (function() {
}, options || {}) }, options || {})
initAttributes.call(this, values) initAttributes.call(this, values)
this.sequelize._metric('DAO.construct', tk.time() - start);
} }
Utils._.extend(DAO.prototype, Mixin.prototype) Utils._.extend(DAO.prototype, Mixin.prototype)
......
...@@ -36,6 +36,7 @@ module.exports = (function() { ...@@ -36,6 +36,7 @@ module.exports = (function() {
} }
}.bind(this)).setMaxListeners(100) }.bind(this)).setMaxListeners(100)
this.sequelize._metric('Query.run', tk.time() - start);
return this return this
} }
......
...@@ -287,7 +287,7 @@ module.exports = (function() { ...@@ -287,7 +287,7 @@ module.exports = (function() {
}) })
query.on('sql', function(sql) { query.on('sql', function(sql) {
emitter.emit('sql', sql) emitter.emit('sql', sql)
}) });
}).run() }).run()
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!