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

Commit 0749e113 by Sascha Depold

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

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