Define a Model
Basic Model Definition
struct User
include CQL::ActiveRecord::Model(Int64)
db_context MyDB, :users
property id : Int64?
property name : String
property email : String
property created_at : Time?
property updated_at : Time?
def initialize(@name : String, @email : String)
end
endKey Components
1. Include the Active Record Module
2. Set the Database Context
3. Define Properties
4. Create a Constructor
Primary Key Types
Integer (default)
UUID
ULID (for sortable IDs)
Excluding Fields from Persistence
Adding Custom Methods
Verify Your Model
Common Issues
Related
Last updated
Was this helpful?