|
|
|
@ -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](), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|