This Northwind-style example models a purchase order as a header plus explicit
line items. OrderItem represents the many-to-many relationship between
purchase orders and products while keeping mutations executable with the
current single-link syntax.
{{#include ../../examples/store.geli}}
cargo run -p gelite-cli -- schema apply examples/store.geli --database store.db
cargo run -p gelite-cli -- repl --database store.dbInsert a customer and two products, keeping their generated IDs:
insert Customer {
email := "margo@example.com",
name := "Margo Hosho",
tier := "gold"
}
insert Product {
sku := "CASE-NOTEBOOK",
name := "Detective Notebook",
price := 12.5,
active := true
}
insert Product {
sku := "OWL-PIN",
name := "Owl Enamel Pin",
price := 8.0,
active := true
}
Create the purchase order and its items in one interactive transaction. Replace the placeholders with generated IDs and the ID printed by the purchase order insert:
start transaction
insert PurchaseOrder {
order_no := "TRIAL-0001",
status := "paid",
ordered_at := "2026-08-03T10:00:00Z",
customer := "<margo-id>"
}
insert OrderItem {
quantity := 2,
unit_price := 12.5,
purchase := "<purchase-order-id>",
product := "<notebook-id>"
}
insert OrderItem {
quantity := 1,
unit_price := 8.0,
purchase := "<purchase-order-id>",
product := "<pin-id>"
}
commit
select OrderItem {
line_total := f64(.quantity) * .unit_price,
product: {
sku,
name
},
purchase: {
order_no,
status,
customer: {
name,
tier
}
}
}
filter .purchase.status in ["paid", "shipped"]
and .product.active = true
order by f64(.quantity) * .unit_price desc
Computed projections are executed by SQLite. Their current REPL column labels are generated implementation aliases rather than the logical output names.