Sync indices on startup
This commit is contained in:
1 parent
ce3e7cf384
commit
bdf23a45b7
1 file changed
+7
@@ -91,6 +91,13 @@ class MongoDB {
|
|||||||
appSettings = new AppSettings({});
|
appSettings = new AppSettings({});
|
||||||
await appSettings.save();
|
await appSettings.save();
|
||||||
}
|
}
|
||||||
|
// Sync indexes
|
||||||
|
const models = mongoose.modelNames();
|
||||||
|
for (const modelName of models) {
|
||||||
|
const model = mongoose.model(modelName);
|
||||||
|
await model.syncIndexes();
|
||||||
|
}
|
||||||
|
|
||||||
logger.info({ message: "Connected to MongoDB" });
|
logger.info({ message: "Connected to MongoDB" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error({
|
logger.error({
|
||||||
|
|||||||
Reference in new issue
Block a user