A module exports a function that can be called with a loopback 3 application to sync indexes between loopback models and databases.
npm install loopback-sync-indices
const syncIndexes = require('loopback-sync-indices');
const app = loopback();
syncIndexes(app);
syncIndexes(app, options)
- app: loopback application
- options.maxRetryCount (Number = 3): maximum number of retries
- options.dropIndexes (Boolean = false): whether to remove db indexes that are not in loopback
- options.recreateIndexesErrorCodes (Array = ['IndexOptionsConflict', 'IndexKeySpecsConflict']): error codes to recreate conflicting indexes.
- options.reservedIndexes (Array = ['_id_']): indexes not to be dropped from db.
- Supports only MongoDB connector.
- Add support for other connectors.