Documentation ¶
Overview ¶
Package grit/db implements the basic CRUD operations used to interact with grit data. All operations are atomic.
Index ¶
- type Database
- func (d *Database) CheckNode(nodeID int64) error
- func (d *Database) Close() error
- func (d *Database) CreateChildOfDateNode(date, name string) (int64, error)
- func (d *Database) CreateLink(originID, destID int64) (int64, error)
- func (d *Database) CreateLinkFromDateNode(date string, destID int64) (int64, error)
- func (d *Database) CreateNode(name string, parentID int64) (int64, error)
- func (d *Database) CreateTree(node *multitree.Node, parentID int64) (int64, error)
- func (d *Database) CreateTreeAsChildOfDateNode(date string, node *multitree.Node) (int64, error)
- func (d *Database) DeleteLinkByEndpoints(originID, destID int64) error
- func (d *Database) DeleteNode(id int64) ([]*multitree.Node, error)
- func (d *Database) DeleteNodeRecursive(id int64) ([]*multitree.Node, error)
- func (d *Database) GetGraph(nodeID int64) (*multitree.Node, error)
- func (d *Database) GetLink(linkID int64) (*multitree.Link, error)
- func (d *Database) GetLinkByEndpoints(originID, destID int64) (*multitree.Link, error)
- func (d *Database) GetLinksByNodeID(nodeID int64) ([]*multitree.Link, error)
- func (d *Database) GetNode(id int64) (*multitree.Node, error)
- func (d *Database) GetNodeByAlias(alias string) (*multitree.Node, error)
- func (d *Database) GetNodeByName(name string) (*multitree.Node, error)
- func (d *Database) GetRoots() ([]*multitree.Node, error)
- func (d *Database) Open(fp string) error
- func (d *Database) RenameNode(nodeID int64, name string) error
- func (d *Database) SetAlias(nodeID int64, alias string) error
- func (d *Database) UncheckNode(nodeID int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
func (*Database) CheckNode ¶
CheckNode marks the node as completed, along with all its direct and indirect successors. The rest of the multitree is updated to reflect the change.
func (*Database) CreateChildOfDateNode ¶
CreateChildOfDateNode atomically creates a node and links the date node to it. Date node is created if it doesn't exist.
func (*Database) CreateLinkFromDateNode ¶
CreateLinkFromDateNode atomically creates an link with date node as the origin. Date node is automatically created if it doesn't exist.
func (*Database) CreateNode ¶
CreateNode creates a node and returns its ID. It updates the status of other nodes in the multitree if needed.
func (*Database) CreateTree ¶
CreateTree saves an entire tree in the database and returns the root ID. It updates the status of other nodes in the multitree to reflect the change.
func (*Database) CreateTreeAsChildOfDateNode ¶
CreateTreeAsChildOfDateNode atomically creates a tree and links the date node to its root. Date node is created if it doesn't exist.
func (*Database) DeleteLinkByEndpoints ¶
func (*Database) DeleteNode ¶
DeleteNode deletes a single node and propagates the change to the rest of the multitree. It returns the node's orphaned successors.
func (*Database) DeleteNodeRecursive ¶
DeleteNodeRecursive deletes the tree rooted at the given node and updates the multitree. Nodes that have parents outside of this tree are preserved. It returns a slice of all deleted nodes.
func (*Database) GetGraph ¶
GetGraph builds a multitree using Breadth-First Search, and returns the requested node as part of the multitree.
func (*Database) GetLinkByEndpoints ¶
func (*Database) GetLinksByNodeID ¶
GetLinksByNodeID gets the node's incoming and outcoming links.
func (*Database) GetNodeByAlias ¶
GetNode returns the node with the given alias, or nil if it doesn't exist.
func (*Database) GetNodeByName ¶
GetNode returns the node with the given name, or nil if it doesn't exist.
func (*Database) UncheckNode ¶
UncheckNode sets the node's status to inactive, along with all its direct and indirect successors. The rest of the multitree is updated to reflect the change.