Documentation ¶
Index ¶
- Constants
- type Collection
- func (c *Collection) DeleteNode(update *Node) error
- func (c *Collection) DeleteNodes(updates []*Node) error
- func (c *Collection) LoadNode(nodeID int64, withContent bool) (*Node, error)
- func (c *Collection) LoadNodes(nodeIDs []int64, withContent bool) ([]*Node, error)
- func (c *Collection) LoadNodesInSequence(nodeIDs []int64, withContent bool) ([]*Node, error)
- func (c *Collection) NewNode() (*Node, error)
- func (c *Collection) NewNodes(count int) ([]*Node, error)
- func (c *Collection) UpdateNode(update *Node) error
- func (c *Collection) UpdateNodes(updates []*Node) error
- type Connection
- func (c *Connection) CloneCollection(sourceName string, cloneName string) error
- func (c *Connection) Close() error
- func (c *Connection) Collection(name string) (*Collection, error)
- func (c *Connection) Collections() (collections []string, err error)
- func (c *Connection) LoggingEnabled() bool
- func (c *Connection) Ping() error
- func (c *Connection) RemoveCollection(name string) error
- func (c *Connection) SetLogging(logging bool)
- type Flag
- type GenericData
- type GenericDataSlice
- type Node
- type SQLString
Constants ¶
const SQLCloneCollection = "insert into {{.targetCollection}} select * from {{.sourceCollection}};"
SQLCloneCollection perform a record by record from source table into (empty) target table
const SQLCollection = `select tbl_name, type from sqlite_master where tbl_name = ?;`
SQLCollection find a single table name
const SQLCollections = `select tbl_name from sqlite_master where type = "table" and tbl_name != "sqlite_sequence" order by tbl_name;`
SQLCollections lists all tables in SQLite database
const SQLDropCollection = `DROP TABLE IF EXISTS "{{.collection}}";`
SQLDropCollection deletes a table permanently - no undoing this
const SQLInsertNode = `` /* 139-byte string literal not displayed */
SQLInsertNode insert a new node into the collection
const SQLListQuery = `` /* 152-byte string literal not displayed */
SQLListQuery read all nodes under a provided up-ID and optionally narrow down certain type-IDs
const SQLLoadNode = `` /* 137-byte string literal not displayed */
SQLLoadNode read a single record by id from selected table (collection)
const SQLLoadNodes = `` /* 153-byte string literal not displayed */
SQLLoadNodes read a set of record by ids from selected table (collection)
const SQLNewCollection = `` /* 919-byte string literal not displayed */
SQLNewCollection creates the scheme and the indexes for the node
const SQLRecursiveAxis = `` /* 711-byte string literal not displayed */
SQLRecursiveAxis reads records recursively to find all descendents of a single node under a specified axis. It keeps a level info. This query can be stopped at a maximum level and/or at a limit of returned records count
const SQLUpdateNode = `` /* 176-byte string literal not displayed */
SQLUpdateNode update a single node in the collection
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { Conn *Connection Name string }
func (*Collection) DeleteNode ¶
func (c *Collection) DeleteNode(update *Node) error
func (*Collection) DeleteNodes ¶
func (c *Collection) DeleteNodes(updates []*Node) error
func (*Collection) LoadNode ¶
func (c *Collection) LoadNode(nodeID int64, withContent bool) (*Node, error)
LoadNode loads a node by its ID, provide withContent = true, if the payload (content) should be loaded with the node.
func (*Collection) LoadNodes ¶
func (c *Collection) LoadNodes(nodeIDs []int64, withContent bool) ([]*Node, error)
func (*Collection) LoadNodesInSequence ¶
func (c *Collection) LoadNodesInSequence(nodeIDs []int64, withContent bool) ([]*Node, error)
func (*Collection) NewNode ¶
func (c *Collection) NewNode() (*Node, error)
NewNode creates and inserts a new node into the collection (runs SQL insert command), this way a node has allways a valid ID The ID may never be zero. A node that you use in your code must allways have a valid representation in the database.
func (*Collection) UpdateNode ¶
func (c *Collection) UpdateNode(update *Node) error
func (*Collection) UpdateNodes ¶
func (c *Collection) UpdateNodes(updates []*Node) error
type Connection ¶
type Connection struct { DB *sql.DB RootID int64 Created time.Time Start time.Time End time.Time Deleted time.Time // contains filtered or unexported fields }
Connection provide access to the database
func Open ¶
func Open(filename string) (*Connection, error)
Open creates a new Connection Object and opens the underlying sqlite database
func (*Connection) CloneCollection ¶
func (c *Connection) CloneCollection(sourceName string, cloneName string) error
CloneCollection makes a full copy of source collection in a new clone collection
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes the underlying sqlite database
func (*Connection) Collection ¶
func (c *Connection) Collection(name string) (*Collection, error)
Collection opens (and creates) collections
func (*Connection) Collections ¶
func (c *Connection) Collections() (collections []string, err error)
Collections returs a string of collection names
func (*Connection) LoggingEnabled ¶
func (c *Connection) LoggingEnabled() bool
LoggingEnabled returns true if logging is enabled, false otherwise
func (*Connection) RemoveCollection ¶
func (c *Connection) RemoveCollection(name string) error
RemoveCollection removes collections, it is destructive, no undo possible!
func (*Connection) SetLogging ¶
func (c *Connection) SetLogging(logging bool)
SetLogging to true or false, default is false
type Flag ¶
type Flag int64
const ( First Flag = 1 << (62 - iota) // first node in a sequence of nodes (the head of a double-linked-list) Bidirectional // in relational node this points in both directions, not the usual left->right Content // node has a Content, this needs to be loaded separately, needs to be set if one of the following is set )
func (Flag) IsBidirectional ¶
type GenericData ¶
type GenericData map[string]interface{}
func GenericDataFromBytes ¶
func GenericDataFromBytes(bytes []byte) (GenericData, error)
func (GenericData) Bytes ¶
func (g GenericData) Bytes() ([]byte, error)
type GenericDataSlice ¶
type GenericDataSlice []map[string]interface{}
func GenericDataSliceFromBytes ¶
func GenericDataSliceFromBytes(bytes []byte) (GenericDataSlice, error)
func (GenericDataSlice) Bytes ¶
func (gs GenericDataSlice) Bytes() ([]byte, error)
type Node ¶
type Node struct { ID int64 TypeID int64 OwnerID int64 Flags Flag Created time.Time Start time.Time End time.Time Deleted time.Time Up int64 Left int64 Right int64 Text string // should be short < 2 KB Content []byte // contains filtered or unexported fields }
func QueryList ¶
func QueryList(collection *Collection, upID int64, withContent bool, typeids ...int64) ([]*Node, error)
QueryList finds all Nodes with provided parentID (up) and and optional list of typeids. It first queries the database and then builds a sequence ordered by the left-right-axis. There may be more then one list in the result set, check for start nodes with left==0 or end nodes with right == 0 It reports an error if the number of sequenced nodes differs from the number of nodes return by the data base query. The result set may still be usable.
func (*Node) IsContentLoaded ¶
func (*Node) SetContentLoaded ¶
type SQLString ¶
type SQLString string
SQLString provide changed text replacements to form a valid sql string
func (SQLString) Collection ¶
helper: replaces collection name template
func (SQLString) WithContent ¶
helper: replaces commaContent, handles with or without content variations