Models and fields

Generate a SQL table, Rust model and five CRUD endpoints from a model definition.

▶ Watch the demo
On this page

Create a model

  1. Press a and name the model, for example User.
  2. Name a field, choose its type and toggle options with Space.
  3. Add fields or a relationship from Model fields.
  4. Select Finish and generate, confirm the collection path, then Generate.

id is added automatically. Use field names such as first_name. Escape cancels before generation.

shell
miblo add User name:string email:string:unique --yes
miblo add Product title:string price:float active:bool --yes

--path /members changes the collection path. Without fields or --yes, the CLI starts its wizard.

Field types

TypeRustSQLiteMySQL
stringStringTEXTVARCHAR(255)
textStringTEXTTEXT
inti64INTEGERBIGINT
floatf64REALDOUBLE
boolboolINTEGERBOOLEAN

Optional fields use Option<T>. Syntax: name:type?:option, for example description:text?.

Options and private fields

OptionExampleBehavior
Optionalnickname:string?Accepts NULL.
Uniqueemail:string:uniqueAdds a unique constraint. Use string, rather than text, for unique text.
Privatetoken:string:privateAccepts writes; omits the value from CRUD responses.

Common sensitive names (password, password_hash, secret, token, api_key) become private through the CLI. This filtering does not encrypt data or add authentication.

Generated CRUD

MethodUser pathResult
GET/usersPaginated list: limit and offset, at most 100 rows per page.
POST/usersCreate: 201.
GET/users/{id}Row or 404.
PATCH/users/{id}Update supplied fields; omitted fields remain unchanged.
DELETE/users/{id}Delete: 204; missing row: 404.

Unknown fields and invalid types are rejected. Unique conflicts return 409. Empty PATCH requests, changing id and NULL for required fields are rejected.

Keep existing project changes

Adding a model writes its files and migration without regenerating existing resources. Registries, miblo.yaml and .miblo/state.json are updated.

--dry-run previews the plan. File collisions or managed registry conflicts stop the operation. Use miblo edit or m to add a field.

Search for a feature or command.

↑ ↓ browse Enter to open