vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

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

Authors

Sönke Ludwig

Copyright

© 2012-2016 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.