Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 67394b63
authored
Oct 02, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass sequelize instance to queries
1 parent
5c567796
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
10 deletions
lib/dialects/mysql/connector-manager.js
lib/dialects/mysql/query.js
lib/dialects/postgres/connector-manager.js
lib/dialects/postgres/query.js
lib/dialects/sqlite/connector-manager.js
lib/dialects/sqlite/query.js
lib/dialects/mysql/connector-manager.js
View file @
67394b6
...
@@ -14,7 +14,9 @@ module.exports = (function() {
...
@@ -14,7 +14,9 @@ module.exports = (function() {
this
.
activeQueue
=
[]
this
.
activeQueue
=
[]
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
poolCfg
=
this
.
config
.
pool
this
.
poolCfg
=
this
.
config
.
pool
var
self
=
this
var
self
=
this
if
(
this
.
poolCfg
)
{
if
(
this
.
poolCfg
)
{
//the user has requested pooling, so create our connection pool
//the user has requested pooling, so create our connection pool
if
(
!
this
.
poolCfg
.
maxConnections
)
{
if
(
!
this
.
poolCfg
.
maxConnections
)
{
...
@@ -32,6 +34,7 @@ module.exports = (function() {
...
@@ -32,6 +34,7 @@ module.exports = (function() {
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
})
})
}
}
process
.
on
(
'exit'
,
function
()
{
process
.
on
(
'exit'
,
function
()
{
//be nice & close our connections on exit
//be nice & close our connections on exit
if
(
self
.
pool
)
{
if
(
self
.
pool
)
{
...
@@ -43,16 +46,16 @@ module.exports = (function() {
...
@@ -43,16 +46,16 @@ module.exports = (function() {
return
return
})
})
}
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
var
isConnecting
=
false
var
isConnecting
=
false
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
if
(
!
this
.
isConnected
&&
!
this
.
pool
)
this
.
connect
()
if
(
!
this
.
isConnected
&&
!
this
.
pool
)
this
.
connect
()
var
queueItem
=
{
var
queueItem
=
{
query
:
new
Query
(
this
.
client
,
callee
,
options
||
{}),
query
:
new
Query
(
this
.
client
,
this
.
sequelize
,
callee
,
options
||
{}),
sql
:
sql
sql
:
sql
}
}
...
...
lib/dialects/mysql/query.js
View file @
67394b6
var
Utils
=
require
(
"../../utils"
)
var
Utils
=
require
(
"../../utils"
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
client
,
callee
,
options
)
{
var
Query
=
function
(
client
,
sequelize
,
callee
,
options
)
{
var
self
=
this
var
self
=
this
this
.
client
=
client
this
.
client
=
client
this
.
callee
=
callee
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
this
.
sequelize
=
sequelize
this
.
options
=
Utils
.
_
.
extend
({
logging
:
console
.
log
,
logging
:
console
.
log
,
plain
:
false
,
plain
:
false
,
raw
:
false
raw
:
false
...
...
lib/dialects/postgres/connector-manager.js
View file @
67394b6
...
@@ -26,7 +26,7 @@ module.exports = (function() {
...
@@ -26,7 +26,7 @@ module.exports = (function() {
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
var
self
=
this
var
self
=
this
if
(
this
.
client
==
null
)
this
.
connect
()
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
self
.
pendingQueries
+=
1
return
query
.
run
(
sql
)
return
query
.
run
(
sql
)
.
success
(
function
()
{
self
.
endQuery
.
call
(
self
)
})
.
success
(
function
()
{
self
.
endQuery
.
call
(
self
)
})
...
...
lib/dialects/postgres/query.js
View file @
67394b6
var
Utils
=
require
(
"../../utils"
);
var
Utils
=
require
(
"../../utils"
);
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
client
,
callee
,
options
)
{
var
Query
=
function
(
client
,
sequelize
,
callee
,
options
)
{
var
self
=
this
var
self
=
this
this
.
client
=
client
this
.
client
=
client
this
.
sequelize
=
sequelize
this
.
callee
=
callee
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
this
.
options
=
Utils
.
_
.
extend
({
logging
:
console
.
log
,
logging
:
console
.
log
,
...
...
lib/dialects/sqlite/connector-manager.js
View file @
67394b6
...
@@ -10,7 +10,7 @@ module.exports = (function() {
...
@@ -10,7 +10,7 @@ module.exports = (function() {
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
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
return
ConnectorManager
...
...
lib/dialects/sqlite/query.js
View file @
67394b6
var
Utils
=
require
(
"../../utils"
)
var
Utils
=
require
(
"../../utils"
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
database
,
callee
,
options
)
{
var
Query
=
function
(
database
,
sequelize
,
callee
,
options
)
{
this
.
database
=
database
this
.
database
=
database
this
.
sequelize
=
sequelize
this
.
callee
=
callee
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
this
.
options
=
Utils
.
_
.
extend
({
logging
:
console
.
log
,
logging
:
console
.
log
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment