Unfortunately your suggestion on adding an index in a model doesn’t work for me. MongoDB offers a lot of functionality - but often this requires a custom index. So in this case I need a 2dsphere index otherwise I simply can’t query the data via Mongoose because it’s not valid to make a geographic query without first having the index.
Here’s the output of Mongoose during bootstrap. You can clearly see on that last line my index being dropped. At the moment I’ve no data, so generation will be super quick, but later on it could cost a not insignificant amount of time to regenerate, so ideally I wan’t Strapi to just leave it alone.
❯ npm run strapi dev
> traders@0.1.0 strapi /home/ian/src/traders
> strapi "dev"
Mongoose: companies.createIndex({ email: 1 }, { unique: true, background: true })
Mongoose: trade_types.createIndex({ name: 1 }, { unique: true, background: true })
Mongoose: strapi_role.createIndex({ name: 1 }, { unique: true, background: true })
Mongoose: strapi_administrator.createIndex({ firstname: 1 }, { unique: false, background: true })
Mongoose: users-permissions_role.createIndex({ type: 1 }, { unique: true, background: true })
Mongoose: users-permissions_user.createIndex({ username: 1 }, { unique: true, background: true })
Mongoose: companies.listIndexes()
Mongoose: faqs.listIndexes()
Mongoose: teams.listIndexes()
Mongoose: tags.listIndexes()
Mongoose: why_blocks.listIndexes()
Mongoose: trade_types.listIndexes()
Mongoose: core_store.listIndexes()
Mongoose: strapi_webhooks.listIndexes()
Mongoose: strapi_permission.listIndexes()
Mongoose: strapi_role.createIndex({ code: 1 }, { unique: true, background: true })
Mongoose: strapi_administrator.createIndex({ lastname: 1 }, { unique: false, background: true })
Mongoose: strapi_administrator.listIndexes()
Mongoose: users-permissions_role.listIndexes()
Mongoose: users-permissions_permission.listIndexes()
Mongoose: strapi_role.listIndexes()
Mongoose: upload_file.listIndexes()
Mongoose: users-permissions_user.listIndexes()
Mongoose: companies.dropIndex('geo')