module CQL::Relations
The CQL::Relations
module provides utilities for managing relationships between tables in a database schema. It allows you to define associations such as has_many
, belongs_to
, and many_to_many
, enabling easy navigation and querying of related data.
Example: Defining Relations
Methods
has_many(relation_name : Symbol)
Defines a has_many
relationship between the current model and another.
@param relation_name [Symbol] The name of the related model.
@return [Nil]
Example:
belongs_to(relation_name : Symbol)
Defines a belongs_to
relationship between the current model and another.
@param relation_name [Symbol] The name of the related model.
@return [Nil]
Example:
many_to_many(relation_name : Symbol, through : Symbol)
Defines a many_to_many
relationship between two models through a join table.
@param relation_name [Symbol] The name of the related model.
@param through [Symbol] The name of the join table.
@return [Nil]
Example:
Last updated