indexes

protected open val indexes: IndexBuilder.() -> Unit? = null

Defines indexes on the table to improve query performance.

This property allows you to create one or more indexes on columns or expressions using a DSL. Indexes can significantly speed up data retrieval operations, especially on large tables. You can define both unique and non-unique indexes.

Example:

object Products : KQLiteTable("products") {
val id = longColumn("id").primaryKey().autoIncrement()
val name = stringColumn("name")
val category = stringColumn("category")
val price = doubleColumn("price")

// Defines a non-unique index on the 'category' column
// and a unique index on 'name'
override val indexes: (IndexBuilder.() -> Unit) = {
index(category)
uniqueIndex(name)
}
}

Author

MOHAMMAD AZIM ANSARI

See also