Skip to content

Commit d979cbf

Browse files
tilacogpcarranzav
andcommitted
Let connection pool size be configured
Co-authored-by: Pablo Carranza Velez <[email protected]>
1 parent f300c97 commit d979cbf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/common-ts/src/database/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ interface ConnectOptions {
77
password: string
88
database: string
99
logging?: (sql: string, timing?: number) => void
10+
poolMin?: number
11+
poolMax?: number
1012
}
1113

1214
export const connectDatabase = async (options: ConnectOptions): Promise<Sequelize> => {
1315
const { host, username, password, database, logging } = options
1416

1517
// Use port 5432 by default
1618
const port = options.port || 5432
19+
const poolMin = options.poolMin || 0
20+
const poolMax = options.poolMax || 10
1721

1822
// Connect to the database
1923
const sequelize = new Sequelize({
@@ -24,8 +28,8 @@ export const connectDatabase = async (options: ConnectOptions): Promise<Sequeliz
2428
password,
2529
database,
2630
pool: {
27-
max: 10,
28-
min: 0,
31+
max: poolMax,
32+
min: poolMin,
2933
},
3034
logging,
3135
})

0 commit comments

Comments
 (0)