module Cql::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:

relations/has_many.cr

Macro Summary

Macro Detail

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

[View source]