Fetch all MongoDB Indexes for Mirroring to Another Database
(1 min read) 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