Documentation
¶
Index ¶
- Constants
- Variables
- func BetweenCreateTime(start, end time.Time) func(db *gorm.DB) *gorm.DB
- func Connect(dbtype, dbaddress string, args map[string]interface{}) (*gorm.DB, error)
- func Migrate(db *gorm.DB) error
- func NestedSelect(table interface{}, selects []string) func(db *gorm.DB) *gorm.DB
- type CacheManageHash
- type CacheManageHashField
- type Discount
- type Order
- type Preload
- type Shop
- type User
- type UserItem
- type UserItemCell
Constants ¶
View Source
const ( HasMany = "has_many" BelongsTo = "belongs_to" HasOne = "has_one" ManyToMany = "many_to_many" )
Gorm field relations Kind
Variables ¶
View Source
var ( PreloadShop = CreatePreload(&Shop{}) PreloadOrder = CreatePreload(&Order{}) PreloadCacheManageHash = CreatePreload(&CacheManageHash{}) )
Functions ¶
Types ¶
type CacheManageHash ¶
type CacheManageHash struct {
gorm.Model
Key string `gorm:"type:varchar(256);unique_index"`
Fields []CacheManageHashField `gorm:"ForeignKey:HashId"`
}
db struct
type CacheManageHashField ¶
type CacheManageHashField struct {
ID uint `gorm:"primary_key"`
HashId uint `gorm:"index:idx_hash_field"`
Field string `gorm:"type:varchar(100);index:idx_hash_field"`
Value string
}
db struct
type Order ¶
type Order struct {
gorm.Model
ShopAddr string `gorm:"type:varchar(1024);index"`
Shop Shop `gorm:"ForeignKey:ShopAddr"`
Tag string `gorm:"type:varchar(64);unique_index:idx_tag_endat"`
Items []UserItem `gorm:"ForeignKey:OrderId"`
User *User `gorm:"ForeignKey:UserName"`
UserName *string `gorm:"type:varchar(256);`
EndAt *time.Time `gorm:"unique_index:idx_tag_endat"`
}
db struct
type Preload ¶
type Preload struct {
All func(db *gorm.DB) *gorm.DB
HasMany func(db *gorm.DB) *gorm.DB
HasOne func(db *gorm.DB) *gorm.DB
BelongsTo func(db *gorm.DB) *gorm.DB
ManyToMany func(db *gorm.DB) *gorm.DB
}
func CreatePreload ¶
func CreatePreload(table interface{}) *Preload
type Shop ¶
type Shop struct {
gorm.Model
Address string `gorm:"type:varchar(1024);unique_index"`
BeginPrice int
BeginCost int
Discounts []Discount `gorm:"ForeignKey:ShopId`
}
db struct
type User ¶
type User struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
Name string `gorm:"type:varchar(256);primary_key"`
Pass string
}
db struct
type UserItem ¶
type UserItem struct {
ID uint `gorm:"primary_key"`
OrderId uint `gorm:"unique_index:idx_order_user;index"`
Cell []UserItemCell `gorm:"ForeignKey:UserItemId"`
User User `gorm:"ForeignKey:UserName"`
UserName string `gorm:"type:varchar(256);unique_index:idx_order_user"`
}
db struct
Click to show internal directories.
Click to hide internal directories.