from("tasks") returns loosely typed rows. With types, the compiler knows each table’s columns, and a typo in eq("donee", false) is an error in your editor instead of a bug in production.
How it works
Each resource compiles to an OpenAPI description: a read model, a create body and an update body per table.generateTypes turns that into a TypeScript Database interface you pass to createClient.
The create body tells which columns are required, which the generator uses to separate “always present” from “may be null”.
Generate
- From a script
- Per resource
npm run types script, and commit the file.
Use
Insert requires the required columns, Update makes everything optional, and Row has everything the server returns.
Without generation
You can write the shape by hand for a few tables:Python
Python has no generated types, but the client is typed and rows are plain dictionaries. Use aTypedDict or a dataclass of your own at the edge:
Keep types honest
- Types are generated from the definition, so they reflect your columns, not the data’s mess. A column marked nullable is typed
| null. - Generate types from the same environment your app reads from, so they match what it gets back.
- Treat the generated file as read-only; change columns in Studio or code and regenerate.
Columns and types
What the types come from.
API Explorer
See the compiled description.