Scaffold CRUD
Given a table, scaffold-crud generates a bundle of endpoints that
cover the standard CRUD operations. Available from the console and as
a REST endpoint:
POST /api/namespaces/:slug/databases/:dbSlug/endpoints/scaffold-crudContent-Type: application/json
{ "table": "orders", "operations": ["list", "get", "create", "update", "delete"]}operations is optional — the default is all five.
What it produces
Section titled “What it produces”For a table orders with columns (id INTEGER PK, customer_id INTEGER, total REAL, status TEXT):
| Slug | Kind | SQL | Output |
|---|---|---|---|
list-orders | query | SELECT * FROM orders LIMIT ? OFFSET ? | rows |
get-order | query | SELECT * FROM orders WHERE id = ? | first_row |
create-order | mutation | INSERT INTO orders (customer_id, total, status) VALUES (?, ?, ?) | rows_written |
update-order | mutation | UPDATE orders SET customer_id = ?, total = ?, status = ? WHERE id = ? | rows_written |
delete-order | mutation | DELETE FROM orders WHERE id = ? | rows_written |
Field types are inferred from the column types (INTEGER → integer,
REAL/NUMERIC → number, TEXT/CLOB → text, etc.). Primary-key
columns are excluded from create inputs (the DB autoincrements).
NOT NULL columns become required: true.
Idempotent on re-run
Section titled “Idempotent on re-run”If a slug already exists (e.g. you ran scaffold-crud once and added a column), the new attempt returns:
{ "ok": true, "data": { "created": [/* newly created endpoints */], "skipped": [{ "slug": "list-orders", "reason": "Slug already exists" }] }}You won’t lose existing endpoints. To regenerate, delete them first.
When to scaffold vs hand-write
Section titled “When to scaffold vs hand-write”Scaffold-crud is the right answer for boilerplate plumbing — list
this, get-by-id that, basic create/update/delete. As soon as you want
joins, computed columns, soft deletes, RBAC beyond $user_id, or
non-trivial filtering, write the spec by hand.
You can also call this from the agent: “scaffold CRUD for the orders
table” → propose_scaffold_crud → confirm → run.