module

Prostore

prostore — declarative ORM for Crystal targeting SQLite and PostgreSQL.

See doc/adr/ for the architectural decisions.

Constants

Q = Query::Q

Convenience top-level constant.

VERSION = "0.5.0"

Class methods

__reset_for_test

Reset the registry. Used in tests; not part of the public API.

Source
connect(url : String) : Connection
Source
default_connection
Source
default_connection=(conn : Connection | Nil)
Source
default_connection?
Source
delete_all(models : Array(Prostore::Model.class) = Prostore.models, conn : Connection = Prostore.default_connection) : Nil

Delete all rows from models in reverse FK dependency order (children before parents). Safe for test teardown when foreign_keys=ON.

Source
migrate(url : String, models : Array(Prostore::Model.class) = Prostore.models) : Nil

High-level entry: bootstrap or migrate the database referenced by url. Opens a temporary connection, migrates, then closes it. For in-memory SQLite use Prostore.setup(url) instead, which reuses the connection.

Source
migrate(conn : Connection, models : Array(Prostore::Model.class) = Prostore.models) : Nil

Migrate using a pre-opened connection. The caller retains ownership of conn and is responsible for closing it. Use this when migrate and the subsequent app queries must share the same underlying database — most importantly for sqlite3::memory: where each DB.open is a distinct, empty database.

Source
models
Source
setup(url : String, models : Array(Prostore::Model.class) = Prostore.models) : Connection

Open, migrate, and set as the default connection in one call. Returns the connection so the caller can close it on shutdown. Prefer this over separate migrate(url) + connect(url) for sqlite3::memory: databases.

Source
test_reset(models : Array(Prostore::Model.class) = Prostore.models, conn : Connection = Prostore.default_connection) : Nil

Convenience alias for test teardown — identical to delete_all.

Source

Nested types