class

Prostore::Model

Inherits Reference < Object

Base class for all prostore-managed models.

Subclasses declare their schema in the class body via the macros installed by inherited and the macros defined in macros.cr. At compile time, a Prostore::Schema::Definition value is built and exposed as Class.prostore_schema.

Class methods

__prostore_builder_for(model_class : T.class) forall T

Build a query Builder for the given model class using the default Prostore connection. Used by macro-emitted class methods.

Source

Instance methods

__prostore_mark_persisted!
Source
persisted?
Source

Macros

field(tag, name, type, **opts)

field tag, :name, Type, **opts

Options (ADR-0011, 0013, 0014): primary: Bool (default false) auto_increment: Bool (default false; requires Int32/Int64 + primary) default: SQL.expr | Proc (new-row strategy) backfill: SQL.expr | Proc (existing-row strategy) lazy: Proc (mutex with default: / backfill:; requires T?)

Source
foreign_key(tag, columns, **opts)

foreign_key tag, [:cols], references: TargetClass, ...

Source
index(tag, columns, **opts)

index tag, [:cols], unique: false, where: SQL.expr(...), name: "..."

Source
query(name, lambda)

query :name, ->(args) { body }

The lambda body is walked as an AST chain; each method call becomes a Schema::Call record consumed by Query::Analyzer for index planning.

Source
reserved(tag)

reserved tag — permanently retire a field tag (ADR-0002).

Source
reserved_foreign_key(tag)
Source
reserved_index(tag)
Source
sequence(*args, **kwargs)

Reserved DSL keyword for future standalone sequences (ADR-0013). Currently excluded; only auto_increment: true on integer PKs is supported.

Source
table_name(name)

table_name "users" — overrides the default snake-case derivation.

Source