Skip to content

Commit 8949291

Browse files
authored
Merge pull request #15740 from Automattic/vkarpov15/autocreate-fix
fix(model): respect autoCreate set on global after creating connection
2 parents c8ccd90 + c173340 commit 8949291

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,11 @@ Model.syncIndexes = async function syncIndexes(options) {
13181318
throw new MongooseError('Model.syncIndexes() no longer accepts a callback');
13191319
}
13201320

1321-
const autoCreate = options?.autoCreate ?? this.schema.options?.autoCreate ?? this.db.config.autoCreate ?? true;
1321+
const autoCreate = options?.autoCreate ??
1322+
this.schema.options?.autoCreate ??
1323+
this.db.config.autoCreate ??
1324+
this.db.base?.options?.autoCreate ??
1325+
true;
13221326

13231327
if (autoCreate) {
13241328
try {

0 commit comments

Comments
 (0)