Documentation
¶
Index ¶
- func GuessStructTags(ci *schema.ColumnInfo) string
- func GuessTypeName(ci *schema.ColumnInfo) string
- func IgnoreNotFoundError(err error) error
- func MoveEdge(query *gorm.DB, base uint, offset string) (err error)
- func Paginate(query *gorm.DB, out interface{}, pageno, pagesize int) (total int, err error)
- type FilterFunc
- type ITableComment
- type ITableName
- type Model
- type NestedNode
- type SqlTag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GuessTypeName ¶
func GuessTypeName(ci *schema.ColumnInfo) string
根据数据库字段类型猜测Go类型,适用于mysql或pgsql
Types ¶
type Model ¶
type Model struct {
ID uint `json:"id" toml:"-" gorm:"primary_key;not null;auto_increment"`
}
*
- 带自增主键的基础Model
func (Model) TableComment ¶ added in v0.5.5
type NestedNode ¶ added in v0.6.0
type NestedNode struct { Lft uint `json:"-" gorm:"not null;default:0;comment:'左边界'"` // 左边界 Rgt uint `json:"-" gorm:"not null;index;default:0;comment:'右边界'"` // 右边界 Depth uint8 `json:"depth" gorm:"not null;index;default:1;comment:'高度'"` // 高度 }
嵌套集合树
func (*NestedNode) AddToParent ¶ added in v0.6.0
func (n *NestedNode) AddToParent(parent *NestedNode, tbQuery *gorm.DB) error
添加到父节点最末,tbQuery一定要使用db.Table(...)
func (NestedNode) AncestorsFilter ¶ added in v0.6.0
func (n NestedNode) AncestorsFilter(Backward bool) FilterFunc
找出所有直系祖先节点
func (NestedNode) ChildrenFilter ¶ added in v0.6.0
func (n NestedNode) ChildrenFilter(rank uint8) FilterFunc
找出所有子孙节点
Click to show internal directories.
Click to hide internal directories.