orm

package
v0.0.1-45c8966 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LAVEL_USER_BLOCK int = iota
	LEVEL_USER_ADMIN
	LAVEL_USER_NORMAL
)
View Source
const (
	ClientProxyMode_Trojan = "trojan"
)

Variables

This section is empty.

Functions

func AutoMigrate

func AutoMigrate(dst ...interface{}) error

func DB

func DB() *gorm.DB

func Initialize

func Initialize() (err error)

Types

type Node

type Node struct {
	gorm.Model

	NodeName string `json:"nodeName"`
	NodeAddr string `json:"nodeAddr"`
	NodePort string `json:"nodePort"`
	NodeTag  string `json:"nodeTag"`

	ClientAddr      string `json:"clientAddr"`
	ClientPort      string `json:"clientPort"`
	ClientProxyMode string `json:"clientProxyMode"`

	Users []User `gorm:"many2many:node_user;"`
}

func (*Node) Sync

func (n *Node) Sync(c context.Context)

type Object

type Object struct {
	*gorm.DB

	Driver, DSN string
}

type Token

type Token struct {
	gorm.Model

	Token  string
	UserID int
	User   User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

type User

type User struct {
	gorm.Model

	Email    string `json:"email" gorm:"email,unique,omitempty"`
	Password string `json:"password" gorm:"password,omitempty"`
	Role     int    `json:"role" gorm:"role,omitempty"`
	Hash     string `json:"-" gorm:"hash,omitempty"`
	Token    string `json:"token"`
	Locked   bool   `json:"locked"`

	Nodes []Node `json:"nodes" gorm:"many2many:node_user;"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate()

Jump to

Keyboard shortcuts

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