private static void dropIndexIfExists(MongoCollection<Document> col, String fieldName) { for (Document d : col.listIndexes()) { if (d.get("key", Document.class).containsKey(fieldName)) { logger.warn("Schema migration. Dropping index: " + fieldName + " ..."); try { col.dropIndex(fieldName); } catch (Exception swallowed) { } // because not implemented in Fongo return; } } }
@Override public void dropIndex(Bson arg0) { coll.dropIndex(arg0); }
@Override public void dropIndex(String arg0) { coll.dropIndex(arg0); }