MongoCollection.dropIndex

Drops a single index from the collection by the index name.

  1. void dropIndex(string name, DropIndexOptions options)
  2. void dropIndex(T keys, IndexOptions indexOptions, DropIndexOptions options)
  3. void dropIndex(IndexModel keys, DropIndexOptions options)
    struct MongoCollection
    @safe
    void
    dropIndex
    (
    const IndexModel keys
    ,
    DropIndexOptions options = DropIndexOptions.init
    )

Throws

Exception if it is attempted to pass in *. Use dropIndexes() to remove all indexes instead.

Examples

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);
}

Meta