kmongo / org.litote.kmongo.reactor / com.mongodb.reactor.client.ReactorMongoCollection / ensureUniqueIndex

ensureUniqueIndex

fun <T> ReactorMongoCollection<T>.ensureUniqueIndex(vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): Mono<Void> (source)

Create an IndexOptions.unique 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> ReactorMongoCollection<T>.ensureUniqueIndex(clientSession: ClientSession, vararg properties: KProperty<*>, indexOptions: IndexOptions = IndexOptions()): Mono<Void> (source)

Create an IndexOptions.unique 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