CRUD scaffolding
crud add is the fastest path from a model to a working UI. It generates a
service, a list panel, a form panel, the RPC contracts, and an optional menu wire.
Walkthrough
# 1. database + modelvsceasy db initvsceasy model add --name user \ --fields "id:string!,name:string,email?:string@,role:\"admin\"|\"user\",active:boolean"
# 2. full CRUD, wired into a new menuvsceasy crud add --model user --menu new:adminReload the window and open the admin menu. You get:
- A list panel: table of rows, Refresh, + New, Edit, Delete.
- A form panel: typed inputs (text, number, checkbox, select for unions).
- A service (
UserService) sitting between the RPC handlers and the repo.
What’s generated
src/services/UserService.ts business logic over UsersRepo()src/services/userFormNav.ts list → form edit hand-offsrc/panels/usersList.ts list panel definition + RPCsrc/panels/userForm.ts form panel definition + RPCsrc/webview/panels/usersList/ list React UIsrc/webview/panels/userForm/ form React UIsrc/shared/api.ts UsersListApi + UserFormApi appendedBehavior built in
The scaffold handles the webview gotchas for you:
- Live list. The list reloads on focus/visibility and after a save, plus a manual Refresh button — because webviews keep state when hidden.
- Host-side delete. Delete confirms with a native modal, since browser
confirm()is disabled in webviews. - Edit pre-fill. Edit stashes the row id; the form pulls it on mount and
pre-fills via
get(id). Creating a new row clears the form afterward.
Customizing
A generated crud.config.ts lets you hide fields or relabel columns:
export default { fields: { createdAt: { hideInForm: true }, email: { label: 'Email address' }, },};Re-run crud add after editing the config, or tweak the generated panels
directly — they’re yours.