(overrides: MongoClientOptions)
| 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')); |
no test coverage detected