Remove the T4C stuff but have an example of using null.

master
Zed A. Shaw 7 days ago
parent 32cd1ff495
commit f63e8475b0
  1. 21
      data/models.go

@ -17,26 +17,17 @@ type User struct {
Password string `db:"password" validate:"required,min=8,max=64"`
}
type Message struct {
/*
* Example of using the null library to do optional fields.
*/
type NullExample struct {
Id int `db:"id" json:"id" validate:"numeric"`
Text string `db:"text" json:"text" validate:"required,max=512"`
UserId int `db:"user_id" json:"user_id" validate:"numeric"`
CreatedAt string `db:"created_at" json:"created_at"`
Likes int `db:"likes" json:"likes" validate:"numeric"`
Bookmarks int `db:"bookmarks" json:"bookmarks" validate:"numeric"`
ReplyingTo null.Int `db:"replying_to" json:"replying_to" validate:"omitempty,numeric"`
}
type Bookmark struct {
MessageId int `db:"message_id" json:"message_id" validate:"required,numeric"`
UserId int `db:"user_id" json:"user_id" validate:"required,numeric"`
HasMaybe null.Int `db:"replying_to" json:"replying_to" validate:"omitempty,numeric"`
}
func Models() map[string]reflect.Type {
return map[string]reflect.Type{
"user": reflect.TypeFor[User](),
"message": reflect.TypeFor[Message](),
"bookmark": reflect.TypeFor[Bookmark](),
"null_example": reflect.TypeFor[NullExample](),
}
}

Loading…
Cancel
Save