Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateUserTableSQL ¶
CreateUserTableSQL returns the SQL for creating the users table
Types ¶
type CustomUser ¶
type CustomUser struct {
ID int64 `gom:"id,primaryAuto"`
Username string `gom:"username,notnull"`
Email string `gom:"email,notnull"`
Age int `gom:"age,notnull"`
Active bool `gom:"active,notnull"`
Role string `gom:"role,notnull"`
CreatedAt time.Time `gom:"created_at,notnull"`
UpdatedAt time.Time `gom:"updated_at,notnull"`
}
CustomUser implements ITableModel interface
func (*CustomUser) CreateSql ¶
func (u *CustomUser) CreateSql() string
CreateSql returns a custom CREATE TABLE SQL statement
func (*CustomUser) TableName ¶
func (u *CustomUser) TableName() string
TableName returns a custom table name
type User ¶
type User struct {
ID int64 `gom:"id,@"`
Username string `gom:"username,unique,notnull"`
Email string `gom:"email,unique,notnull"`
Age int `gom:"age,notnull,default:18"`
Active bool `gom:"active,notnull,default:true"`
Role string `gom:"role,notnull,default:'user'"`
CreatedAt time.Time `gom:"created_at"`
UpdatedAt time.Time `gom:"updated_at"`
}
User represents a user model
type UserProfile ¶
type UserProfile struct {
ID int64 `gom:"id,@"`
UserID int64 `gom:"user_id,notnull,foreignkey:users.id"`
Avatar string `gom:"avatar,notnull,default:'/default.png'"`
Bio string `gom:"bio"`
Location string `gom:"location"`
CreatedAt time.Time `gom:"created_at"`
UpdatedAt time.Time `gom:"updated_at"`
}
UserProfile demonstrates more complex relationships
Click to show internal directories.
Click to hide internal directories.