module CQL::Record(Pk)
Write documentation for Record module
Example Using the Record module
Instance Methods
def attributes(attrs : Hash(Symbol, DB::Any))
(attrs : Hash(Symbol, DB::Any))
Set the record's attributes from a hash
@param attrs [Hash(Symbol, DB::Any)] The attributes to set
@return [Nil]
Example Setting the record's attributes
def attributes
Define instance-level methods for querying and manipulating data Fetch the record's ID or raise an error if it's nil
@return [PrimaryKey] The ID
Example Fetching the record's ID
def delete
Delete the record from the database
@return [Nil]
Example Deleting the record
def id
Identity method for the record ID
@return [PrimaryKey] The ID
Example Fetching the record's ID
def id=(id : Pk)
(id : Pk)
Set the record's ID
@param id [PrimaryKey] The ID
Example Setting the record's ID
def persisted?
Check if the record has been persisted to the database
@return [Bool] True if the record has an ID, false otherwise
Example Checking if the record is persisted
def reload!
Define instance-level methods for querying and manipulating data Fetch the record's ID or raise an error if it's nil
@return [PrimaryKey] The ID
Example Fetching the record's ID
def save
Define instance-level methods for saving and deleting records Save the record to the database or update it if it already exists
@return [Nil]
Example Saving the record
def update(fields : Hash(Symbol, DB::Any))
(fields : Hash(Symbol, DB::Any))
Delete the record from the database if it exists
@return [Nil]
Example Deleting the record
def update
Update the record with the given record object
Example Updating the record
def update
Update the record with the given fields
@param fields [Hash(Symbol, DB::Any)] The fields to update
@return [Nil]
Example Updating the record
Last updated