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 f5f1cb15
authored
Nov 17, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored pg lib usage
1 parent
a254cacd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
lib/dialects/postgres/connector-manager.js
lib/dialects/postgres/connector-manager.js
View file @
f5f1cb1
var
Query
=
require
(
"./query"
)
var
Query
=
require
(
"./query"
)
,
Utils
=
require
(
"../../utils"
)
,
Utils
=
require
(
"../../utils"
)
,
pg
=
require
(
"pg"
)
,
without
=
function
(
arr
,
elem
)
{
return
arr
.
filter
(
function
(
e
)
{
return
e
!=
elem
})
}
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
ConnectorManager
=
function
(
sequelize
,
config
)
{
var
ConnectorManager
=
function
(
sequelize
,
config
)
{
this
.
sequelize
=
sequelize
this
.
sequelize
=
sequelize
this
.
client
=
null
this
.
client
=
null
this
.
config
=
config
||
{}
this
.
config
=
config
||
{}
this
.
pooling
=
(
this
.
config
.
poolCfg
!=
null
&&
this
.
config
.
poolCfg
.
maxConnections
>
0
)
this
.
pooling
=
(
!!
this
.
config
.
poolCfg
&&
(
this
.
config
.
poolCfg
.
maxConnections
>
0
))
if
(
this
.
config
.
native
)
{
this
.
pg
=
this
.
config
.
native
?
require
(
'pg'
).
native
:
require
(
'pg'
)
pg
=
pg
.
native
}
// set pooling parameters if specified
// set pooling parameters if specified
if
(
this
.
pooling
)
{
if
(
this
.
pooling
)
{
pg
.
defaults
.
poolSize
=
this
.
config
.
poolCfg
.
maxConnections
this
.
pg
.
defaults
.
poolSize
=
this
.
config
.
poolCfg
.
maxConnections
pg
.
defaults
.
poolIdleTimeout
=
this
.
config
.
poolCfg
.
maxIdleTime
this
.
pg
.
defaults
.
poolIdleTimeout
=
this
.
config
.
poolCfg
.
maxIdleTime
}
}
this
.
disconnectTimeoutId
=
null
this
.
disconnectTimeoutId
=
null
this
.
pendingQueries
=
0
this
.
pendingQueries
=
0
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
...
@@ -71,11 +69,10 @@ module.exports = (function() {
...
@@ -71,11 +69,10 @@ module.exports = (function() {
if
(
this
.
pooling
)
{
if
(
this
.
pooling
)
{
// acquire client from pool
// acquire client from pool
pg
.
connect
(
uri
,
connectCallback
)
this
.
pg
.
connect
(
uri
,
connectCallback
)
}
else
{
}
else
{
//create one-off client
//create one-off client
this
.
client
=
new
pg
.
Client
(
uri
)
this
.
client
=
new
this
.
pg
.
Client
(
uri
)
this
.
client
.
connect
(
connectCallback
)
this
.
client
.
connect
(
connectCallback
)
}
}
}
}
...
...
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