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

Function _createCollection

lib/model.js:1155–1179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

model.jsFile · 0.85

Calls 1

createCollectionMethod · 0.80

Tested by

no test coverage detected