arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

CQL Documentation

A high-performance, type-safe ORM for Crystal applications.

Build fast, reliable database applications with compile-time safety and exceptional performance.

hashtag
Quick Navigation

I want to...

Go to...

hashtag
Installation

Add CQL to your shard.yml:

Then run:

hashtag
Quick Start

hashtag
Documentation Structure

hashtag
Tutorials

Learning-oriented - Step-by-step guides for beginners

  • - Build your first application

  • - Complete multi-part tutorial

hashtag
How-to Guides

Task-oriented - Practical steps to accomplish specific goals

  • - Define, validate, and enhance models

  • - Set up associations

  • - Find and filter data

hashtag
Reference

Information-oriented - Technical descriptions and specifications

  • - Common patterns at a glance

  • - Terminology definitions

  • - Error messages explained

hashtag
Explanation

Understanding-oriented - Conceptual discussions

  • - ORM fundamentals

  • - Design pattern overview

hashtag
Key Features

  • Type Safety - Catch errors at compile time

  • Multiple Databases - PostgreSQL, MySQL, SQLite

  • Active Record - Familiar patterns for rapid development

hashtag
Getting Help

  • - Frequently asked questions

  • - Common issues

  • - Get support

hashtag
License

CQL is available under the MIT license.

- Manage schema changes
Migrations - Version-controlled schema changes
  • Validations - Built-in data integrity

  • Relationships - belongs_to, has_one, has_many, many-to-many

  • Soft Deletes - Mark records as deleted

  • Optimistic Locking - Prevent concurrent update conflicts

  • - Report bugs

    Learn CQL from scratch

    Accomplish a specific task

    Look up API details

    Understand concepts

    Full installation guide
    Your First CQL App
    Building a Blog
    Models
    Relationships
    Querying
    Quick Reference
    Glossary
    Error Codes
    What is an ORM?
    Active Record Pattern
    FAQ
    Troubleshooting
    Community
    dependencies:
      cql:
        github: azutoolkit/cql
        version: ~> 0.0.435
    
      # Choose your database driver:
      pg:  # PostgreSQL
        github: will/crystal-pg
        version: "~> 0.26.0"
    shards install
    require "cql"
    require "pg"
    
    # Define your database
    MyDB = CQL::Schema.define(
      :my_db,
      adapter: CQL::Adapter::Postgres,
      uri: "postgres://localhost/myapp"
    ) do
    end
    
    # Define a model
    struct User
      include CQL::ActiveRecord::Model(Int64)
      db_context MyDB, :users
    
      property id : Int64?
      property name : String
      property email : String
    
      def initialize(@name : String, @email : String)
      end
    end
    
    # Use it
    MyDB.init
    user = User.create!(name: "Alice", email: "alice@example.com")
    puts "Created user #{user.id}: #{user.name}"
    Migrations
    GitHub Issuesarrow-up-right
    Tutorials
    How-to Guides
    Reference
    Explanation