Skip to content

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-crud
Content-Type: application/json
{
"table": "orders",
"operations": ["list", "get", "create", "update", "delete"]
}

operations is optional — the default is all five.

For a table orders with columns (id INTEGER PK, customer_id INTEGER, total REAL, status TEXT):

SlugKindSQLOutput
list-ordersquerySELECT * FROM orders LIMIT ? OFFSET ?rows
get-orderquerySELECT * FROM orders WHERE id = ?first_row
create-ordermutationINSERT INTO orders (customer_id, total, status) VALUES (?, ?, ?)rows_written
update-ordermutationUPDATE orders SET customer_id = ?, total = ?, status = ? WHERE id = ?rows_written
delete-ordermutationDELETE FROM orders WHERE id = ?rows_written

Field types are inferred from the column types (INTEGERinteger, REAL/NUMERICnumber, TEXT/CLOBtext, etc.). Primary-key columns are excluded from create inputs (the DB autoincrements). NOT NULL columns become required: true.

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.

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.