Documentation
¶
Index ¶
- func Create(db *gorm.DB, source, parent interface{}) error
- func Delete(db *gorm.DB, source interface{}) error
- func MoveTo(db *gorm.DB, node, to interface{}, direction MoveDirection) error
- func Rebuild(db *gorm.DB, source interface{}, doUpdate bool) (affectedCount int, err error)
- func RebuildBatched(db *gorm.DB, source interface{}, doUpdate bool, batchSize int) (affectedCount int, err error)
- type MoveDirection
- type Tree
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create a new node within its parent by Gorm original Create() method ```nestedset.Create(db, &Category{...}, nil)``` will create a new category in root level ```nestedset.Create(db, &Category{...}, &parent)``` will create a new category under parent node as its last child
func Delete ¶
Delete a node from scoped list and its all descendent ```nestedset.Delete(db, &Category{...})```
func MoveTo ¶
func MoveTo(db *gorm.DB, node, to interface{}, direction MoveDirection) error
MoveTo move node to a position which is related a target node ```nestedset.MoveTo(db, &node, &to, nestedset.MoveDirectionInner)``` will move [&node] to [&to] node's child_list as its first child
func Rebuild ¶ added in v1.4.0
Rebuild rebuild nodes as any nestedset which in the scope ```nestedset.Rebuild(db, &node, true)``` will rebuild [&node] as nestedset
func RebuildBatched ¶ added in v1.6.0
func RebuildBatched(db *gorm.DB, source interface{}, doUpdate bool, batchSize int) (affectedCount int, err error)
RebuildBatched rebuild nodes as any nestedset which in the scope ```nestedset.RebuildBatched(db, &node, true, 1000)``` will rebuild [&node] as nestedset
Types ¶
type MoveDirection ¶
type MoveDirection int
MoveDirection means where the node is going to be located
const ( // MoveDirectionLeft : MoveTo(db, a, n, MoveDirectionLeft) => a|n|... MoveDirectionLeft MoveDirection = -1 // MoveDirectionRight : MoveTo(db, a, n, MoveDirectionRight) => ...|n|a| MoveDirectionRight MoveDirection = 1 // MoveDirectionInner : MoveTo(db, a, n, MoveDirectionInner) => [n [...|a]] MoveDirectionInner MoveDirection = 0 )
MoveDirections ...
