React edits to circumnavigate DB issue

Some devs have been working on an issue with our DB. Whilst not finding it yet, they have suggested some changes we could make to avoid the error occurring. So this task is to find work arounds which achieve the same functionality but in different ways.

Here’s the relevant discussion copy/pasted:

Removing listIndexes calls from our codebase
A global search of listIndexes in your project after opening it in gitpod yields no results (though it may be called by ensureIndex ). This is a total shot in the dark, but make sure you’re not using the admin database for your application - i.e. that the database name at the end of your mongodb connection string is not “admin”.

I know MongoDB and NodeJS reasonably well but React and Meteor not at all. That said, it looks like this line is what is interrogating the indexes (calling listIndexes on the MongoDB collection):
https://github.com/focallocal/fl-maps/blob/ef5a4e184b0a30a6cc5fe3e620a01f27aa324c23/imports/both/collections/events/index.js#L572
The line is: Events._ensureIndex({ ‘address.location’: ‘2dsphere’ })
I would suggest commenting out that line to see if it resolves the issue. Obviously it’s creating an index that is required so searching by address.location in the Events collection may be slow - depending on the number of records in the collection - until you can find a proper fix.

Following up on some of the feedback you’ve received, it’s clear that your code is calling ensureIndex (https://github.com/focallocal/fl-maps/blob/ea6c71a1a1d24440f1be493d88a9c4e681203708/imports/both/collections/events/index.js#L572 ). From the code that was linked, the ensureIndex function (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L132) calls indexInformation (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L279), which in turn calls listIndexes (https://github.com/mongodb/node-mongodb-native/blob/2b18411d2f57e06d11262d5a308c56a9f561789e/lib/operations/db_ops.js#L305) which appears to be where the problem is triggered.

This task is no-longer needed as the site is fixed. I’ll keep it here in case we run into this issue again so we don’t need to do all of this work again.