MCPcopy Create free account
hub / github.com/Automattic/mongoose / _createCollection

Function _createCollection

lib/model.js:1316–1332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

model.jsFile · 0.85

Calls 1

createCollectionMethod · 0.80

Tested by

no test coverage detected