()
| 1314 | return await this.ensureIndexes({ _automatic: true }); |
| 1315 | }; |
| 1316 | const _createCollection = async() => { |
| 1317 | if ((conn.readyState === STATES.connecting || conn.readyState === STATES.disconnected) && conn._shouldBufferCommands()) { |
| 1318 | await new Promise(resolve => { |
| 1319 | conn._queue.push({ fn: resolve }); |
| 1320 | }); |
| 1321 | } |
| 1322 | const autoCreate = utils.getOption( |
| 1323 | 'autoCreate', |
| 1324 | this.schema.options, |
| 1325 | conn.config, |
| 1326 | conn.base.options |
| 1327 | ); |
| 1328 | if (!autoCreate) { |
| 1329 | return; |
| 1330 | } |
| 1331 | return await this.createCollection(); |
| 1332 | }; |
| 1333 | |
| 1334 | this.$init = _createCollection().then(() => _ensureIndexes()); |
| 1335 |
no test coverage detected