example

package
v4.0.3-ai Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUserTableSQL

func CreateUserTableSQL(driver string) string

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

type UserQuery

type UserQuery struct {
	MinAge    *int       `gom:"min_age"`
	MaxAge    *int       `gom:"max_age"`
	Username  string     `gom:"username"`
	Email     string     `gom:"email"`
	IsActive  *bool      `gom:"is_active"`
	CreatedAt *time.Time `gom:"created_at"`
}

UserQuery represents a query model for users

type UserRole

type UserRole struct {
	ID          int64     `gom:"id,@"`
	Name        string    `gom:"name,unique,notnull"`
	Description string    `gom:"description,notnull"`
	CreatedAt   time.Time `gom:"created_at"`
	UpdatedAt   time.Time `gom:"updated_at"`
}

UserRole represents a role model to demonstrate foreign key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL