MCPcopy
hub / github.com/Automattic/mongoose / _createCollection

Function _createCollection

lib/model.js:1154–1178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1152 return await this.createSearchIndexes();
1153 };
1154 const _createCollection = async() => {
1155 let autoCreate = utils.getOption(
1156 'autoCreate',
1157 this.schema.options,
1158 conn.config
1159 // No base.options here because we don't want to take the base value if the connection hasn't
1160 // set it yet
1161 );
1162 if (autoCreate == null) {
1163 // `autoCreate` may later be set when the connection is opened, so wait for connect before checking
1164 await conn._waitForConnect(true);
1165 autoCreate = utils.getOption(
1166 'autoCreate',
1167 this.schema.options,
1168 conn.config,
1169 conn.base.options
1170 );
1171 }
1172
1173 if (!autoCreate) {
1174 return;
1175 }
1176
1177 return await this.createCollection();
1178 };
1179
1180 this.$init = _createCollection().
1181 then(() => _ensureIndexes()).

Callers 1

model.jsFile · 0.85

Calls 1

createCollectionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…