Quick Start: Adding a Data Model
Automated Option
Use the generator to scaffold everything:
# Interactive
task addmodel
# Non-interactive
go run ./gojang/cmd/addmodel \
--model SampleProduct \
--icon "📦" \
--fields "name:string:required,price:float:required,stock:int,description:text"
Manual Steps (overview)
- Create Ent schema in
gojang/models/schema/
- Run
cd gojang/models && go generate ./...
- Create form struct in
gojang/views/forms/
- Create handlers in
gojang/http/handlers/
- Create routes in
gojang/http/routes/
and register inmain.go
- Create templates in
gojang/views/templates/<model>/
- Register model in
gojang/admin/models.go
Quick Checklist
- Define schema
- Generate Ent code
- Create handler & routes
- Create templates
- Register in admin
- Test CRUD and admin pages
This quick start walks through adding a SampleProduct model and verifies basic CRUD and admin integration.