class CQL::Index
Reference
< Object
The CQL::Index
class represents an index on a table. Indexes are used to optimize query performance by providing faster access to data. This class provides methods for defining the columns that make up the index and specifying whether the index is unique.
Example: Creating an Index
Constructors
def new(table : Table, columns : Array(Symbol), unique : Bool = false)
Creates a new index on the specified table.
@param table [Table] The table on which the index is created.
@param columns [Array(Symbol)] The columns that make up the index.
@param unique [Bool] Whether the index should enforce uniqueness (default:
false
).@return [Index] The created index object.
Example:
Methods
def unique
Specifies whether the index is unique.
@return [Bool]
true
if the index is unique,false
otherwise.
Example:
def generate_name
Generates a name for the index based on the table and columns.
@return [String] The generated index name.
Example: