model

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithFields added in v0.2.1

func WithFields(fields ...string) func(*gorm.DB) *gorm.DB

func WithIDEq

func WithIDEq(id string) func(*gorm.DB) *gorm.DB

func WithOrder added in v0.2.1

func WithOrder(order string) func(*gorm.DB) *gorm.DB

func WithRoleEq

func WithRoleEq(role user.Role) func(*gorm.DB) *gorm.DB

func WithStatusEq

func WithStatusEq(status user.Status) func(*gorm.DB) *gorm.DB

func WithUsernameLike added in v0.2.2

func WithUsernameLike(name string) func(*gorm.DB) *gorm.DB

Types

type FollowDevice added in v0.3.0

type FollowDevice struct {
	ID        uint64 `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeviceID  uint64 `gorm:"not null;uniqueIndex:idx_device_user" json:"deviceId"`
	UserID    string `gorm:"not null;type:char(32);uniqueIndex:idx_device_user" json:"userId"`
}

type User

type User struct {
	ID              string `gorm:"primaryKey;type:char(32);index:,type:hash" json:"id"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Username        string          `gorm:"not null;uniqueIndex;type:varchar(32)"`
	HashedPassword  []byte          `gorm:"not null"`
	Role            user.Role       `gorm:"not null;default:0"`
	Status          user.Status     `gorm:"not null;default:0"`
	Email           string          `gorm:"type:varchar(64)"`
	FollowDevices   []*FollowDevice `gorm:"foreignKey:UserID;references:ID"`
	FollowAllDevice sql.NullBool    `gorm:"default:false"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

Jump to

Keyboard shortcuts

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