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

Commit 67394b63 by Sascha Depold

pass sequelize instance to queries

1 parent 5c567796
......@@ -14,7 +14,9 @@ module.exports = (function() {
this.activeQueue = []
this.maxConcurrentQueries = (this.config.maxConcurrentQueries || 50)
this.poolCfg = this.config.pool
var self = this
if (this.poolCfg) {
//the user has requested pooling, so create our connection pool
if (!this.poolCfg.maxConnections) {
......@@ -32,6 +34,7 @@ module.exports = (function() {
idleTimeoutMillis: self.poolCfg.maxIdleTime
})
}
process.on('exit', function () {
//be nice & close our connections on exit
if (self.pool) {
......@@ -43,16 +46,16 @@ module.exports = (function() {
return
})
}
Utils._.extend(ConnectorManager.prototype, require("../connector-manager").prototype)
var isConnecting = false
ConnectorManager.prototype.query = function(sql, callee, options) {
if(!this.isConnected && !this.pool) this.connect()
var queueItem = {
query: new Query(this.client, callee, options || {}),
query: new Query(this.client, this.sequelize, callee, options || {}),
sql: sql
}
......
var Utils = require("../../utils")
module.exports = (function() {
var Query = function(client, callee, options) {
var Query = function(client, sequelize, callee, options) {
var self = this
this.client = client
this.callee = callee
this.options = Utils._.extend({
this.client = client
this.callee = callee
this.sequelize = sequelize
this.options = Utils._.extend({
logging: console.log,
plain: false,
raw: false
......
......@@ -26,7 +26,7 @@ module.exports = (function() {
ConnectorManager.prototype.query = function(sql, callee, options) {
var self = this
if (this.client == null) this.connect()
var query = new Query(this.client, callee, options || {})
var query = new Query(this.client, this.sequelize, callee, options || {})
self.pendingQueries += 1
return query.run(sql)
.success(function() { self.endQuery.call(self) })
......
var Utils = require("../../utils");
module.exports = (function() {
var Query = function(client, callee, options) {
var Query = function(client, sequelize, callee, options) {
var self = this
this.client = client
this.sequelize = sequelize
this.callee = callee
this.options = Utils._.extend({
logging: console.log,
......
......@@ -10,7 +10,7 @@ module.exports = (function() {
Utils._.extend(ConnectorManager.prototype, require("../connector-manager").prototype)
ConnectorManager.prototype.query = function(sql, callee, options) {
return new Query(this.database, callee, options).run(sql)
return new Query(this.database, this.sequelize, callee, options).run(sql)
}
return ConnectorManager
......
var Utils = require("../../utils")
module.exports = (function() {
var Query = function(database, callee, options) {
var Query = function(database, sequelize, callee, options) {
this.database = database
this.sequelize = sequelize
this.callee = callee
this.options = Utils._.extend({
logging: console.log,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!