kmongo / org.litote.kmongo.rxjava2 / com.mongodb.reactivestreams.client.MongoCollection / ensureIndex

ensureIndex

fun <T> MongoCollection<T>.ensureIndex(keys: String, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

key - an object describing the index key(s)

indexOptions - the options for the index

Return
the index name

fun <T> MongoCollection<T>.ensureIndex(clientSession: ClientSession, keys: String, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

clientSession - the client session

key - an object describing the index key(s)

indexOptions - the options for the index

Return
the index name

fun <T> MongoCollection<T>.ensureIndex(keys: Bson, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

keys - an object describing the index key(s)

indexOptions - the options for the index

Return
the index name

fun <T> MongoCollection<T>.ensureIndex(clientSession: ClientSession, keys: Bson, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

clientSession - the client session

keys - an object describing the index key(s)

indexOptions - the options for the index

Return
the index name

fun <T> MongoCollection<T>.ensureIndex(vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

properties - the properties, which must contain at least one

indexOptions - the options for the index

Return
the index name

fun <T> MongoCollection<T>.ensureIndex(clientSession: ClientSession, vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): Completable (source)

Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.

Parameters

clientSession - the client session

properties - the properties, which must contain at least one

indexOptions - the options for the index

Return
the index name