Documentation
¶
Index ¶
- Variables
- func BuildSchema(db *sql.DB) error
- func BuildSchemaWithTableNames(db *sql.DB, edgeTableName, nodeTableName string) error
- func EdgeDeleteByIDs(tx *sql.Tx, edgeIDs ...string) (int64, error)
- func EdgeDeleteByIDsWithTableName(tx *sql.Tx, edgeTableName string, edgeIDs ...string) (int64, error)
- func EdgeDeleteByNodeIDs(tx *sql.Tx, inIDs []string, outIDs []string) (int64, error)
- func EdgeDeleteByNodeIDsWithTableName(tx *sql.Tx, edgeTableName string, inIDs []string, outIDs []string) (int64, error)
- func NewFilter(field string, value any, subFilters ...*filter) *filter
- func NewFilterFull(field, comparison string, value any, subFilterComparision string, ...) *filter
- func NewOrFilter(field string, value any, subFilters ...*filter) *filter
- func NodeDeleteByIDs(tx *sql.Tx, nodeIDs ...string) (int64, error)
- func NodeDeleteByIDsWithTableName(tx *sql.Tx, nodeTableName string, nodeIDs ...string) (int64, error)
- func PropertiesToType[T any](properties []byte) (*T, error)
- type Edge
- func EdgeCreate[T any](tx *sql.Tx, newEdge Edge[T]) (*Edge[T], error)
- func EdgeCreateWithTableName[T any](tx *sql.Tx, edgeTableName string, newEdge Edge[T]) (*Edge[T], error)
- func EdgeGetBy[T any](tx *sql.Tx, filters FilterSet) (*Edge[T], error)
- func EdgeGetByID[T any](tx *sql.Tx, id string) (*Edge[T], error)
- func EdgeGetByIDWithTableName[T any](tx *sql.Tx, edgeTableName, id string) (*Edge[T], error)
- func EdgeGetByWithTableName[T any](tx *sql.Tx, edgeTableName string, filters FilterSet) (*Edge[T], error)
- func EdgeUpdate[T any](tx *sql.Tx, updatedEdge Edge[T], withReturn bool) (*Edge[T], error)
- func EdgeUpdateWithTableName[T any](tx *sql.Tx, edgeTableName string, updatedEdge Edge[T], withReturn bool) (*Edge[T], error)
- func EdgeUpsert[T any](tx *sql.Tx, conflictColumns string, conflictClause string, newEdge Edge[T]) (*Edge[T], error)
- func EdgeUpsertWithTableName[T any](tx *sql.Tx, edgetTableName, conflictColumns, conflictClause string, ...) (*Edge[T], error)
- func GenericEdgeToType[T any](edgeInstance GenericEdge) (*Edge[T], error)
- func NewEdge[T any](id, edgeType, inID, outID string, properties T) *Edge[T]
- type EdgeSet
- func EdgesCreate[T any](tx *sql.Tx, newEdges ...Edge[T]) (*EdgeSet[T], error)
- func EdgesCreateWithTableName[T any](tx *sql.Tx, edgeTableName string, newEdges ...Edge[T]) (*EdgeSet[T], error)
- func EdgesGetBy[T any](tx *sql.Tx, filters *FilterSet) (*EdgeSet[T], error)
- func EdgesGetByWithTableName[T any](tx *sql.Tx, edgeTableName string, filters *FilterSet) (*EdgeSet[T], error)
- func EdgesUpsert[T any](tx *sql.Tx, conflictColumns, conflictClause string, newEdges ...Edge[T]) (*EdgeSet[T], error)
- func EdgesUpsertWithTableName[T any](tx *sql.Tx, edgeTableName, conflictColumns, conflictClause string, ...) (*EdgeSet[T], error)
- func RowsToEdge[T any](rows *sql.Rows, tx *sql.Tx) (*EdgeSet[T], error)
- type FilterSet
- type GenericEdge
- type GenericEdgeNode
- type GenericEdgeNodeSet
- func NodesGetRelatedBy(tx *sql.Tx, nodeID, direction, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
- func NodesGetRelatedByWithTableName(tx *sql.Tx, nodeTableName, edgeTableName, nodeID, direction, edgeType string, ...) (*GenericEdgeNodeSet, error)
- func NodesInRelatedBy(tx *sql.Tx, nodeID, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
- func NodesInRelatedByWithTableName(tx *sql.Tx, nodeID, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
- func NodesOutRelatedBy(tx *sql.Tx, nodeID, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
- func NodesOutRelatedByWithTableName(tx *sql.Tx, nodeTableName, edgeTableName, nodeID, edgeType string, ...) (*GenericEdgeNodeSet, error)
- type GenericNode
- type GenericProperties
- type Node
- func GenericNodeToType[T any](nodeInstance GenericNode) (*Node[T], error)
- func NewNode[T any](id, nodeType string, properties T) *Node[T]
- func NodeCreate[T any](tx *sql.Tx, newNode Node[T]) (*Node[T], error)
- func NodeCreateWithTableName[T any](tx *sql.Tx, nodeTableName string, newNode Node[T]) (*Node[T], error)
- func NodeGetBy[T any](tx *sql.Tx, filters FilterSet) (*Node[T], error)
- func NodeGetByID[T any](tx *sql.Tx, id string) (*Node[T], error)
- func NodeGetByIDWithTableName[T any](tx *sql.Tx, nodeTableName, id string) (*Node[T], error)
- func NodeGetByWithTableName[T any](tx *sql.Tx, nodeTableName string, filters FilterSet) (*Node[T], error)
- func NodeUpdate[T any](tx *sql.Tx, updatedNode Node[T], withReturn bool) (*Node[T], error)
- func NodeUpdateWithTableName[T any](tx *sql.Tx, nodeTableName string, updatedNode Node[T], withReturn bool) (*Node[T], error)
- func NodeUpsert[T any](tx *sql.Tx, conflictColumns string, conflictClause string, newNode Node[T]) (*Node[T], error)
- func NodeUpsertWithTableName[T any](tx *sql.Tx, nodeTableName, conflictColumns, conflictClause string, ...) (*Node[T], error)
- func ResultToNode[T any](row *sql.Row, tx *sql.Tx) (*Node[T], error)
- type NodeSet
- func NodesCreate[T any](tx *sql.Tx, newNodes ...Node[T]) (*NodeSet[T], error)
- func NodesCreateWithTableName[T any](tx *sql.Tx, nodeTableName string, newNodes ...Node[T]) (*NodeSet[T], error)
- func NodesGetBy[T any](tx *sql.Tx, filters *FilterSet) (*NodeSet[T], error)
- func NodesGetByWithTableName[T any](tx *sql.Tx, nodeTableName string, filters *FilterSet) (*NodeSet[T], error)
- func NodesUpsert[T any](tx *sql.Tx, conflictColumns, conflictClause string, newNodes ...Node[T]) (*NodeSet[T], error)
- func NodesUpsertWithTableName[T any](tx *sql.Tx, nodeTableName, conflictColumns, conflictClause string, ...) (*NodeSet[T], error)
- func RowsToNode[T any](rows *sql.Rows, tx *sql.Tx) (*NodeSet[T], error)
- type Time
- type TypedNodeEdge
- type TypedNodeEdgeSet
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BuildSchema ¶
BuildSchema does the work of scaffoling the database and should be called when the connection is created.
func EdgeDeleteByNodeIDs ¶
func NewFilter ¶
NewFilter will create a filter with a default equal (=) Comparision and a default "and" SubFilterComparision
func NewFilterFull ¶
func NewFilterFull(field, comparison string, value any, subFilterComparision string, subFilters ...*filter) *filter
NewFilterFull builds a filter
func NewOrFilter ¶
NewOrFilter will create a filter with a default equal (=) Comparision and a default "or" SubFilterComparision
func PropertiesToType ¶
PropertiesToType will take a byte of properties and unmarshal it into the provided type
Types ¶
type Edge ¶
type Edge[T any] struct { InID string `json:"in_id"` OutID string `json:"out_id"` Properties T // contains filtered or unexported fields }
func EdgeCreate ¶
EdgeCreate will add an edge to the database. The InID and OutID nodes must already exist in the database or are apart of the current transaction
func EdgeCreateWithTableName ¶
func EdgeGetByID ¶
EdgeGetByID will return a typed edge by its id
func EdgeGetByWithTableName ¶
func EdgeUpdate ¶
EdgeUpdate will update the properties on an existing edge
func EdgeUpdateWithTableName ¶
func EdgeUpsert ¶
func EdgeUpsertWithTableName ¶
func GenericEdgeToType ¶
func GenericEdgeToType[T any](edgeInstance GenericEdge) (*Edge[T], error)
GenericEdgeToType will convert a GenericEdge to the provided typed Edge
type EdgeSet ¶
func EdgesCreate ¶
EdgesCreate will add mulitple edges to the database. The InID and OutID nodes for each edge must already exist in the database or are apart of the current transaction
func EdgesGetBy ¶
EdgesGetBy will return a typed EdgeSet and can be extended using a FilterSet
func EdgesGetByWithTableName ¶
func EdgesUpsert ¶
func EdgesUpsert[T any](tx *sql.Tx, conflictColumns, conflictClause string, newEdges ...Edge[T]) (*EdgeSet[T], error)
EdgesUpsert will execute an upsert query based on the conflictColumns and the conflictCluase values
func RowsToEdge ¶
RowsToEdge is a utility method that is used to convert an sql.Rows instance into a typed EdgeSet
type GenericEdge ¶
type GenericEdge Edge[GenericProperties]
type GenericEdgeNode ¶
type GenericEdgeNode struct { GenericEdge GenericNode }
type GenericEdgeNodeSet ¶
type GenericEdgeNodeSet []GenericEdgeNode
func NodesGetRelatedBy ¶
func NodesGetRelatedBy(tx *sql.Tx, nodeID, direction, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
NodesGetRelatedBy will do a single in or out hop from nodeID via the edgeType can be extended with a FilterSet the edge table is aliased as e, and the node table is aliased as n
func NodesInRelatedBy ¶
func NodesInRelatedBy(tx *sql.Tx, nodeID, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
NodesInRelatedBy will do a single in hop from nodeID via the edgeType can be extended with a FilterSet the edge table is aliased as e, and the node table is aliased as n
func NodesOutRelatedBy ¶
func NodesOutRelatedBy(tx *sql.Tx, nodeID, edgeType string, filters *FilterSet) (*GenericEdgeNodeSet, error)
NodesOutRelatedBy will do a single out hop from nodeID via the edgeType can be extended with a FilterSet the edge table is aliased as e, and the node table is aliased as n
type GenericNode ¶
type GenericNode Node[GenericProperties]
type GenericProperties ¶
func (*GenericProperties) Scan ¶
func (g *GenericProperties) Scan(src any) error
Scan does the work of translating the value stored in the database back into GenericProperties
type Node ¶
type Node[T any] struct { Properties T // contains filtered or unexported fields }
func GenericNodeToType ¶
func GenericNodeToType[T any](nodeInstance GenericNode) (*Node[T], error)
GenericNodeToType will convert a GenericNode to the provided typed Node
func NodeCreate ¶
NodeCreate will add a node to the database
func NodeCreateWithTableName ¶
func NodeGetByID ¶
NodeGetByID retrieves and typed node by its id
func NodeGetByWithTableName ¶
func NodeUpdate ¶
NodeUpdate updates a node's properties. updatedNode.ID must exist in the database
func NodeUpdateWithTableName ¶
func NodeUpsert ¶
func NodeUpsert[T any](tx *sql.Tx, conflictColumns string, conflictClause string, newNode Node[T]) (*Node[T], error)
NodeUpsert will execute an upsert query based on the conflictColumns and the conflictCluase values
ex: you have unique constraint on a "user" node's username that looks like:
CREATE UNIQUE INDEX IF NOT EXISTS user_username_idx ON node(type, properties->'username') WHERE type = 'user'
you would pass in "type, properties->'username'" as the conflictColumns and, in this case, "type='user'" as the conflictClause
func NodeUpsertWithTableName ¶
type NodeSet ¶
func NodesCreate ¶
NodesCreate will add mulitple nodes to the database
func NodesGetBy ¶
NodesGetBy will return a typed NodeSet and can be extended using a FilterSet
func NodesGetByWithTableName ¶
func NodesUpsert ¶
func NodesUpsert[T any](tx *sql.Tx, conflictColumns, conflictClause string, newNodes ...Node[T]) (*NodeSet[T], error)
NodesUpsert will execute an upsert query based on the conflictColumns and the conflictCluase values
ex: you have unique constraint on a "user" node's username that looks like:
CREATE UNIQUE INDEX IF NOT EXISTS user_username_idx ON node(type, properties->'username') WHERE type = 'user'
you would pass in "type, properties->'username'" as the conflicedColumns and, in this case, "type='user'" as the conflictClause
func RowsToNode ¶
RowsToNode is a utility method that is used to convert an sql.Rows instance into a typed NodeSet
type Time ¶
Custom time taken from https://www.golang.dk/articles/go-and-sqlite-in-the-cloud
type TypedNodeEdge ¶
type TypedNodeEdgeSet ¶
type TypedNodeEdgeSet[NodeType any, EdgeType any] []TypedNodeEdge[NodeType, EdgeType]
func GenericEdgeNodeSetToTypes ¶
func GenericEdgeNodeSetToTypes[NodeType any, EdgeType any](set GenericEdgeNodeSet) (*TypedNodeEdgeSet[NodeType, EdgeType], error)
func (TypedNodeEdgeSet[NodeType, EdgeType]) Edges ¶
func (ty TypedNodeEdgeSet[NodeType, EdgeType]) Edges() *EdgeSet[EdgeType]
func (TypedNodeEdgeSet[NodeType, EdgeType]) Nodes ¶
func (ty TypedNodeEdgeSet[NodeType, EdgeType]) Nodes() *NodeSet[NodeType]