package data import ( "reflect" "github.com/guregu/null/v6" ) type Login struct { Username string `db:"username" validate:"required,max=30"` Password string `db:"password" validate:"required,max=128"` } type User struct { Id int64 `db:"id" validate:"numeric"` Username string `db:"username" validate:"required,max=30"` Email string `db:"email" validate:"required,email,max=128"` Password string `db:"password" validate:"required,min=8,max=64"` } type Question struct { Id int64 `db:"id" validate:"numeric"` Question string `db:"question"` Result int `db:"result"` Answer bool // move to session } type Survey struct { Id int64 `db:"id" validate:"numeric"` Title string `db:"title"` Description string `db:"description"` CreatedOn string `db:"created_on"` Respondents int `db:"respondents"` State string `db:"state"` Questions []Question } /* * Example of using the null library to do optional fields. */ type NullExample struct { Id int `db:"id" validate:"numeric"` HasMaybe null.Int `db:"replying_to" validate:"omitempty,numeric"` } func Models() map[string]reflect.Type { return map[string]reflect.Type{ "user": reflect.TypeFor[User](), "question": reflect.TypeFor[Question](), "survey": reflect.TypeFor[Survey](), } }