carlos / todomvc-bakeoff Public

Clone
git clone https://amadan.net/carlos/todomvc-bakeoff

Plain git — no account needed to clone.

Download

Download this file

1package todo
2
3import "time"
4
5// Models is every model the schema generator manages. Keep it in step
6// with the structs below: `rastrillo migration generate` reads it to
7// work out what the database should look like, and
8// `rastrillo migration check` fails when it and the migrations disagree.
9var Models = []any{
10 &Visitor{},
11 &Todo{},
12}
13
14// Visitor is one anonymous browser: the owner of one list. Its ID is
15// the session subject (visitor.go), so sessions.UserID returns it and
16// scope.Owned filters on it like any signed-in user's id.
17type Visitor struct {
18 ID int64
19 CreatedAt time.Time
20}
21
22// Todo is one item in a visitor's list. UserID is the owning visitor:
23// Rastrillo's owner column, the one scope.Owned filters on.
24type Todo struct {
25 ID int64
26 UserID int64 `gorm:"index;not null"`
27 Title string
28 Completed bool `gorm:"not null;default:false"`
29 CreatedAt time.Time
30 UpdatedAt time.Time
31}
32