Showcase · Live engine
The library, compiled — not a mock-up.
This page does not re-implement moonorm in JavaScript. It loads the real package compiled to JS and calls its public API. Switch a dialect, flip a toggle, and read the SQL the actual codegen emits.
The model
A Model is built once from a row reader and a row writer. The
example below is the exact source the engine on this page was built from.
Model::new(
"accounts",
[
column("id", BigIntType,
primary_key=true, autoincrement=true),
column("email", TextType,
nullable=false, unique=true),
column("balance", RealType),
column("team_id", BigIntType,
references=("teams", "id"),
on_delete="SET NULL"),
column("status", TextType,
nullable=false, default="'active'"),
column("level", IntType,
checks=["level >= 0"]),
],
from_row, to_row,
)
A table "accounts" with six columns. id → primary key, auto increment email → not null, unique balance → nullable real team_id → fk → teams(id), SET NULL status → not null, default 'active' level → integer, checked >= 0
Generate DDL — pick a dialect
One model, three dialects. The buttons call
create_table_sql_for(dialect) on the loaded engine.
Build a query
The same engine builds a parameterized SELECT. Toggle clauses
and read the SQL plus its bound parameters.
Provenance. This page loads engine/moonorm.js — the
moonorm package compiled to JavaScript with moon build --target js.
It is rebuilt by the docs workflow whenever the library changes, so the
output you read here is always the library's own. No SQL on this page is
hand-authored.