Fetch all MongoDB Indexes for Mirroring to Another Database #115
thecodedrift
announced in
TIL
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I needed a reliable way to take the indexes from a staging instance and ensure they're replicated to production.
The following
_MONGOSH
code loops over every collection and then every index in the collection, creating a "createIndex" command for each combination. This makes it trival to copy indexes from one environment to the other.Credit:
Beta Was this translation helpful? Give feedback.
All reactions