This is an idea for a Twitter clone for programmers, similar to how Dribbble is twitter for designers. It'll most likely not feature any images other than people's avatars, and no videos, or audio. Just text. 'Cause we're coders.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
twitter-for-coders/data/models.go

42 lines
1.3 KiB

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 int `db:"id" json:"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 Message 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"`
}
func Models() map[string]reflect.Type {
return map[string]reflect.Type{
"user": reflect.TypeFor[User](),
"message": reflect.TypeFor[Message](),
"bookmark": reflect.TypeFor[Bookmark](),
}
}