model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccountColumns = struct {
	ID        string
	AccountID string
	UserID    string
	Type      string
	Name      string
}{
	ID:        "id",
	AccountID: "account_id",
	UserID:    "user_id",
	Type:      "type",
	Name:      "name",
}

AccountColumns get sql column name.获取数据库列名

View Source
var UserColumns = struct {
	UserID string
	Name   string
	Sex    string
	Job    string
}{
	UserID: "user_id",
	Name:   "name",
	Sex:    "sex",
	Job:    "job",
}

UserColumns get sql column name.获取数据库列名

Functions

func AccountMgr

func AccountMgr(db *gorm.DB) *_AccountMgr

AccountMgr open func

func CloseRelated

func CloseRelated()

CloseRelated 关闭全局预加载

func OpenRelated

func OpenRelated()

OpenRelated 打开全局预加载

func UserMgr

func UserMgr(db *gorm.DB) *_UserMgr

UserMgr open func

Types

type Account

type Account struct {
	ID        int    `gorm:"primaryKey;column:id;type:int(11);not null" json:"-"`
	AccountID int    `gorm:"uniqueIndex:account;column:account_id;type:int(11)" json:"accountId"`
	UserID    int    `gorm:"uniqueIndex:account;index:tp;column:user_id;type:int(11)" json:"userId"`
	User      User   `gorm:"joinForeignKey:user_id;foreignKey:user_id" json:"userList"`
	Type      int    `gorm:"index:tp;column:type;type:int(11)" json:"type"`
	Name      string `gorm:"column:name;type:varchar(255)" json:"name"`
}

Account [...]

func (*Account) TableName

func (m *Account) TableName() string

TableName get sql table name.获取数据库表名

type Condition

type Condition struct {
	// contains filtered or unexported fields
}

自定义sql查询

func (*Condition) And

func (c *Condition) And(column string, cases string, value interface{}) *Condition

And a Condition by and .and 一个条件

func (*Condition) AndWithCondition

func (c *Condition) AndWithCondition(condition bool, column string, cases string, value interface{}) *Condition

func (*Condition) Get

func (c *Condition) Get() (where string, out []interface{})

func (*Condition) Or

func (c *Condition) Or(column string, cases string, value interface{}) *Condition

Or a Condition by or .or 一个条件

func (*Condition) OrWithCondition

func (c *Condition) OrWithCondition(condition bool, column string, cases string, value interface{}) *Condition

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option overrides behavior of Connect.

type User

type User struct {
	UserID int    `gorm:"primaryKey;column:user_id;type:int(11);not null" json:"-"`
	Name   string `gorm:"column:name;type:varchar(30);not null" json:"name"`
	Sex    int    `gorm:"column:sex;type:int(11);not null" json:"sex"`
	Job    int    `gorm:"column:job;type:int(11);not null" json:"job"`
}

User [...]

func (*User) TableName

func (m *User) TableName() string

TableName get sql table name.获取数据库表名

Jump to

Keyboard shortcuts

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