module CQL::ActiveRecord::Relations::HasMany

Overview

Define the has_many association module that will be included in the model to define a one-to-many relationship between two tables in the database and provide methods to manage the association between the two tables and query records in the associated table based on the foreign key value of the parent record.

Example

class User
  include CQL::Model(User, Int64)
  property id : Int64
  property name : String
  has_many :posts, Post, foreign_key: :user_id
end

Defined in:

active_record/relations/has_many.cr

Macro Summary

Instance Method Summary

Macro Detail

macro has_many(name, type, foreign_key, cascade = false) #

[View source]

Instance Method Detail

def reload_associations #

Reload all associations for the model This method will be overridden in models with associations to reload specific associations


[View source]