mongoose.syncIndexes()
and Connection#syncIndexes()
: run syncIndexes()
on all registered models
#10893
Labels
new feature
This change adds new functionality, like a new method or class
Milestone
So, in mongoose 5.2.0 we introduced Model.syncIndexes(), and I've found that feature quite useful, I'd like to make it easier for people to utilize it.
Following are a few ideas on how we can do that:
mongoose.set('syncIndexes', true);
, which would automatically attempt to syncIndexes on connecting to the database. I assume that most people would expect that changing an index in the schema would reflect on the database, so I'd argue that this option should be set totrue
by default on mongoose v7.mongoose.syncIndexes();
which would internally loop over all the models and sync their indexes. The reasoning behind doing that is because I run multiple instances of node, and would like to usemongoose.syncIndexes();
only on one of the node instances in order to avoid multiple instances trying to sync at once, avoiding possible race conditions.What do you think?
@vkarpov15 @IslandRhythms @ahmedelshenawy25
The text was updated successfully, but these errors were encountered: