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

Commit 0749e113 by Sascha Depold

removed private query method + expose public query method that returns a node-sql instance

1 parent 81d5d2a0
Showing with 11 additions and 15 deletions
......@@ -2,6 +2,7 @@ var Utils = require("./utils")
, DAO = require("./dao")
, DataTypes = require("./data-types")
, Util = require('util')
, Sql = require("sql")
module.exports = (function() {
var DAOFactory = function(name, attributes, options) {
......@@ -519,25 +520,20 @@ module.exports = (function() {
return this.QueryInterface.describeTable(this.tableName)
}
// private
var query = function() {
var args = Utils._.map(arguments, function(arg, _) { return arg })
, sequelize = this.daoFactoryManager.sequelize
DAOFactory.prototype.query = function() {
var dialect = this.daoFactoryManager.sequelize.options.dialect
, instance = new Sql(dialect).define({ name: this.tableName, model: this })
, attributes = this.attributes
// add this as the second argument
if (arguments.length === 1) {
args.push(this)
}
// add {} as options
if (args.length === 2) {
args.push({})
}
Object.keys(attributes).forEach(function(key) {
instance.addColumn(key, attributes[key])
})
return sequelize.query.apply(sequelize, args)
return instance
}
// private
var addOptionalClassMethods = function() {
var self = this
Utils._.each(this.options.classMethods || {}, function(fct, name) { self[name] = fct })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!