Function MongoCollection.dropIndex
Drops a single index from the collection by the index name.
void dropIndex
(
string name,
DropIndexOptions options = DropIndexOptions(Nullable(DontCallDestructorT(), true))
) @safe;
void dropIndex(T)
(
T keys,
IndexOptions indexOptions = IndexOptions .init,
DropIndexOptions options = DropIndexOptions .init
) @safe
if (!is(Unqual!T == IndexModel));
void dropIndex
(
const(IndexModel) keys,
DropIndexOptions options = DropIndexOptions(Nullable(DontCallDestructorT(), true))
) @safe;
Throws
Exception
if it is attempted to pass in *
.
Use dropIndexes() to remove all indexes instead.
Example
import vibe .db .mongo .mongo;
void test()
{
auto coll = connectMongoDB("127.0.0.1") .getCollection("test");
auto primarykey = IndexModel()
.add("name", 1)
.add("primarykey", -1);
coll .dropIndex(primarykey);
}