Mongo (+Mongoose) error: Unable to find index for $geoNear query Mongo (+Mongoose) error: Unable to find index for $geoNear query mongoose mongoose

Mongo (+Mongoose) error: Unable to find index for $geoNear query


The problem was happening only while testing with Mocha. My after(function(done)}); was dropping the entire database at the end of every test file and the indexes where not being created again for the next test.

I solved it by replacing mongoose.connection.db.dropDatabase with Model.remove({}, callback);