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

Commit 54163dc3 by Mick Hansen Committed by Jan Aagaard Meier

picking

1 parent 98cd40a2
......@@ -103,7 +103,7 @@ module.exports = (function() {
}.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)
}
......@@ -150,7 +150,7 @@ module.exports = (function() {
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 })
}
......@@ -180,8 +180,10 @@ module.exports = (function() {
DAOFactory.prototype.build = function(values, options) {
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
this.daoFactoryManager.sequelize._metric('DAOFactory.newDAO', tk.time() - start);
options = options || {}
instance.__factory = this
......@@ -218,7 +220,7 @@ module.exports = (function() {
instance.isNewRecord = options.hasOwnProperty('isNewRecord') ? options.isNewRecord : true
instance.selectedValues = values
this.daoFactoryManager.sequelize._metric('Model.build', tk.time() - start);
this.daoFactoryManager.sequelize._metric('DAOFactory.build', tk.time() - start);
return instance
}
......
......@@ -2,11 +2,14 @@ var Utils = require("./utils")
, Mixin = require("./associations/mixin")
, Validator = require("validator")
var tk = require('timekit');
module.exports = (function() {
var DAO = function(values, options) {
var start = tk.time();
this.attributes = []
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({
underscored: false,
hasPrimaryKeys: false,
......@@ -15,6 +18,8 @@ module.exports = (function() {
}, options || {})
initAttributes.call(this, values)
this.sequelize._metric('DAO.construct', tk.time() - start);
}
Utils._.extend(DAO.prototype, Mixin.prototype)
......
......@@ -36,6 +36,7 @@ module.exports = (function() {
}
}.bind(this)).setMaxListeners(100)
this.sequelize._metric('Query.run', tk.time() - start);
return this
}
......
......@@ -287,7 +287,7 @@ module.exports = (function() {
})
query.on('sql', function(sql) {
emitter.emit('sql', sql)
})
});
}).run()
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!