/// <summary> /// Drop an index from a collection /// </summary> public bool DropIndex(string collection, string field) { if (collection.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(collection)); } if (field.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(field)); } if (field == "_id") { throw LiteException.IndexDropId(); } return(Transaction <bool>(collection, false, (col) => { // no collection, no index if (col == null) { return false; } // search for index reference var index = col.GetIndex(field); // no index, no drop if (index == null) { return false; } _log.Write(Logger.Command, "drop index on '{0}' :: '{1}'", collection, field); // delete all data pages + indexes pages _indexer.DropIndex(index); // clear index reference index.Clear(); // mark collection page as dirty _pager.SetDirty(col); return true; })); }