Skip to content

Commit

Permalink
fix(mongo): allow using pool.min/max options in mongo driver
Browse files Browse the repository at this point in the history
Closes #2228
  • Loading branch information
B4nan committed Sep 23, 2021
1 parent bbd0eb4 commit 9223055
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/mongodb/src/MongoConnection.ts
Expand Up @@ -52,13 +52,22 @@ export class MongoConnection extends Connection {

getConnectionOptions(): MongoClientOptions & ConnectionConfig {
const ret: MongoClientOptions = { useNewUrlParser: true, useUnifiedTopology: true };
const pool = this.config.get('pool')!;
const user = this.config.get('user');
const password = this.config.get('password') as string;

if (user && password) {
ret.auth = { user, password };
}

if (pool.min) {
ret.minPoolSize = ret.minSize = pool.min;
}

if (pool.max) {
ret.maxPoolSize = ret.poolSize = pool.max;
}

return Utils.merge(ret, this.config.get('driverOptions'));
}

Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.ts
Expand Up @@ -43,6 +43,7 @@ export async function initORMMongo() {
populateAfterFlush: true,
validate: true,
filters: { allowedFooBars: { cond: args => ({ id: { $in: args.allowed } }), entity: ['FooBar'], default: false } },
pool: { min: 1, max: 3 },
});

ensureIndexes = false;
Expand Down

0 comments on commit 9223055

Please sign in to comment.