Skip to content

Named queries

Named .eel files are the primary way apps consume Eelden Lang (sqlc-like). Inline templates are an escape hatch.

eel
use schema "../demo_schema.eel"

query ListUsers() {
  users |> select { id, name, email, active, balance, status }
}

query GetPaid(min_balance: Money<usd>) {
  users
  |> filter status == .paid && balance >= ${min_balance}
  |> select { name, balance }
}

Declared params bind ${name} holes in the body. Types are checked against the schema registry (including use schema paths relative to the queries file).

Config

examples/eelden.config.json:

json
{
  "schemas": ["demo_schema.eel"],
  "queries": ["queries/**/*.eel"],
  "outDir": "generated"
}

Codegen

bash
# from clients/typescript after npm run build
node bin/eelden-codegen.mjs --config ../../examples/eelden.config.json

Or, once on your PATH:

bash
eelden-codegen --config eelden.config.json

Emits typed TypeScript functions that return EeldenQuery<TRows> values for an EeldenExecutor to run. See TypeScript client.

ts
import { GetPaid } from "./generated/users.queries";
import { Money } from "@eelden/client";

const rows = await exec.execute(
  GetPaid({ min_balance: Money.minor(5000n, "USD") }),
);

CLI typecheck

bash
eelden typecheck-queries examples/demo_schema.eel examples/queries/users.eel

Or via cargo:

bash
cargo run -p eelden-cli -- typecheck-queries examples/demo_schema.eel examples/queries/users.eel

Transport reality

EeldenExecutor is the contract. A shipping HTTP/IPC driver is not in @eelden/client yet — see Status. Today you drive the engine via eelden run / Studio / wasm, or implement EeldenExecutor against eelden serve's /query for experiments.

Example layout

PathRole
examples/demo_schema.eelSchema
examples/queries/users.eelNamed queries
examples/eelden.config.jsonCodegen config

Pre-alpha. Local-first. Stdlib-only Rust engine. Tenant concerns shifted left into the database.