Quartz

Version, currently master branch1 version
  • master branchlatestJun 15, 2026

github.com/yutsuna/quartz

ORM in Crystal

0 stars
1 dependent
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  Quartz:
    github: yutsuna/quartz
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
>= 1.20.2
License
MIT
Author
Yutsuna
Target
  • Quartz from Source/Quartz.cr

Dependencies

Runtime Dependencies

  • db*github: crystal-lang/crystal-db
  • sqlite3*github: crystal-lang/crystal-sqlite3

README

Quartz

Quartz is a Crystal ORM built around three goals: a compact model DSL, REPL-safe macros, and a storage layer that can be swapped without changing the model API.

Documentation

Quick start

require "./Source/Quartz"

class Author < Quartz::AModel
  field name : String
  has_many books : Book
end

class Book < Quartz::AModel
  field title : String = ""
  belongs_to author : Author

  validates title, presence: true
  before_save { self.title = title.strip }
  timestamps
end

author = Author.objects.create(name: "Léo")
book = Book.objects.create(title: "  Crystal in Practice  ", author_id: author.id)

puts book.inspect
puts book.author
puts author.books
puts Book.objects
  .filter { |item| item.author_id == author.id }
  .order_by { |item| item.title }
  .to_a

Installation

git clone https://github.com/Yutsuna/Quartz.git
cd Quartz
shards install

Quartz targets Crystal >= 1.20.2.

Build and test

We recommand you to use Krystal to build and test Quartz. Krystal is a crystal compiler wrapper for big projects, really faster than crystal build.

krystal
krystal --force
krystal --release
krystal --spec

Project layout

Source/
  Quartz.cr
  Quartz/
    Models/
    Query/
    Adapters/
    Errors/
Spec/
Doc/

Contributing

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Push the branch.
  5. Open a pull request.