a IndexModel or type with integer or string fields indicating index direction or index type.
import vibe.db.mongo.mongo; void test() { auto coll = connectMongoDB("127.0.0.1").getCollection("test"); // simple ascending name, descending primarykey compound-index coll.createIndex(["name": 1, "primarykey": -1]); IndexOptions textOptions = { // pick language from another field called "idioma" languageOverride: "idioma" }; auto textIndex = IndexModel() .withOptions(textOptions) .add("comments", IndexType.text); // more complex text index in DB with independent language coll.createIndex(textIndex); }
Convenience method for creating a single index. Calls createIndexes
Supports any kind of document for template parameter T or a IndexModel.