IndexModel.add

IndexModel add(string field, int direction) ref return @safe

Adds a single field or multikey index with a direction.

Call this method multiple times with different fields to create a compound index.

Parameters

fieldthe name of the field to index
direction1 for ascending or -1 for descending

Returns

this IndexModel instance (caller)
IndexModel add(string field, string type) ref return @safe

Adds an index with a given index type. Use IndexType for a type-safe setting of the string.

Parameters

fieldthe name of the field to index
typethe index type to use

Returns

this IndexModel instance (caller)