package todo import "time" // Models is every model the schema generator manages. Keep it in step // with the structs below: `rastrillo migration generate` reads it to // work out what the database should look like, and // `rastrillo migration check` fails when it and the migrations disagree. var Models = []any{ &Visitor{}, &Todo{}, } // Visitor is one anonymous browser: the owner of one list. Its ID is // the session subject (visitor.go), so sessions.UserID returns it and // scope.Owned filters on it like any signed-in user's id. type Visitor struct { ID int64 CreatedAt time.Time } // Todo is one item in a visitor's list. UserID is the owning visitor: // Rastrillo's owner column, the one scope.Owned filters on. type Todo struct { ID int64 UserID int64 `gorm:"index;not null"` Title string Completed bool `gorm:"not null;default:false"` CreatedAt time.Time UpdatedAt time.Time }