MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / mapOptions

Method mapOptions

packages/mongodb/src/MongoConnection.ts:156–174  ·  view source on GitHub ↗
(overrides: MongoClientOptions)

Source from the content-addressed store, hash-verified

154 }
155
156 mapOptions(overrides: MongoClientOptions): MongoClientOptions {
157 const ret: MongoClientOptions = {};
158 const pool = this.config.get('pool');
159 const username = this.config.get('user');
160 const password = this.config.get('password') as string;
161
162 if (this.config.get('host')) {
163 throw new ValidationError('Mongo driver does not support `host` options, use `clientUrl` instead!');
164 }
165
166 if (username && password) {
167 ret.auth = { username, password };
168 }
169
170 ret.minPoolSize = pool.min;
171 ret.maxPoolSize = pool.max;
172 ret.waitQueueTimeoutMS = pool.idleTimeoutMillis;
173 return Utils.mergeConfig(ret, overrides);
174 }
175
176 getDb(): Db {
177 this.#db ??= this.getClient().db(this.config.get('dbName'));

Callers 1

createClientMethod · 0.95

Calls 2

mergeConfigMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected