simplegraph

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DeleteEdge = `DELETE FROM edges WHERE source = ? OR target = ?
`

	DeleteNode = `DELETE FROM nodes WHERE id = ?
`

	InsertEdge = `INSERT INTO edges VALUES(?, ?, json(?))
`

	InsertNode = `INSERT INTO nodes VALUES(json(?))
`

	Schema = `` /* 555-byte string literal not displayed */

	SearchEdgesInbound = `SELECT * FROM edges WHERE source = ?
`

	SearchEdgesOutbound = `SELECT * FROM edges WHERE target = ?
`

	SearchEdges = `SELECT * FROM edges WHERE source = ? 
UNION
SELECT * FROM edges WHERE target = ?
`

	UpdateNode = `UPDATE nodes SET body = json(?) WHERE id = ?
`

	SearchNodeTemplate = `` /* 214-byte string literal not displayed */

	SearchWhereTemplate = `` /* 287-byte string literal not displayed */

	TraverseTemplate = `` /* 583-byte string literal not displayed */

)
View Source
const (
	SQLITE = "libsql"
	// WITH_FOREIGN_KEY_PRAGMA = "%s?_foreign_keys=true"
	ID_CONSTRAINT        = "NOT NULL constraint failed: nodes.id"
	UNIQUE_ID_CONSTRAINT = "UNIQUE constraint failed: nodes.id"
	NO_ROWS_FOUND        = "sql: no rows in result set"
)

Variables

View Source
var (
	CLAUSE_TEMPLATE   = template.Must(template.New("where").Parse(SearchWhereTemplate))
	SEARCH_TEMPLATE   = template.Must(template.New("search").Parse(SearchNodeTemplate))
	TRAVERSE_TEMPLATE = template.Must(template.New("traverse").Parse(TraverseTemplate))
)

Functions

func AddNode

func AddNode(identifier string, node []byte, database ...string) (int64, error)

func AddNodes

func AddNodes(identifiers []string, nodes [][]byte, database ...string) (int64, error)

func BulkConnectNodes

func BulkConnectNodes(sources []string, targets []string, database ...string) (int64, error)

func BulkConnectNodesWithProperties

func BulkConnectNodesWithProperties(sources []string, targets []string, properties []string, database ...string) (int64, error)

func ConnectNodes

func ConnectNodes(sourceId string, targetId string, database ...string) (int64, error)

func ConnectNodesWithProperties

func ConnectNodesWithProperties(sourceId string, targetId string, properties []byte, database ...string) (int64, error)

func FindNode

func FindNode(identifier string, database ...string) (string, error)

func FindNodes

func FindNodes(statement string, bindings []string, database ...string) ([]string, error)

func GenerateSearchStatement

func GenerateSearchStatement(properties *SearchQuery) string

func GenerateTraversal

func GenerateTraversal(properties *Traversal) string

func GenerateWhereClause

func GenerateWhereClause(properties *WhereClause) string

func Initialize

func Initialize(database ...string)

func RemoveNodes

func RemoveNodes(identifiers []string, database ...string) bool

func TraverseFrom

func TraverseFrom(source string, traversal string, database ...string) ([]string, error)

func TraverseFromTo

func TraverseFromTo(source string, target string, traversal string, database ...string) ([]string, error)

func UpdateNodeBody

func UpdateNodeBody(identifier string, body string, database ...string) error

func UpsertNode

func UpsertNode(identifier string, body string, database ...string) error

Types

type EdgeData

type EdgeData struct {
	Source string
	Target string
	Label  string
}

func Connections

func Connections(identifier string, database ...string) ([]EdgeData, error)

func ConnectionsIn

func ConnectionsIn(identifier string, database ...string) ([]EdgeData, error)

func ConnectionsOut

func ConnectionsOut(identifier string, database ...string) ([]EdgeData, error)

type EdgeSet

type EdgeSet struct {
	// contains filtered or unexported fields
}

func NewEdgeSet

func NewEdgeSet() *EdgeSet

func (*EdgeSet) Add

func (set *EdgeSet) Add(edge EdgeData) bool

func (*EdgeSet) Contains

func (set *EdgeSet) Contains(edge EdgeData) bool

type GraphData

type GraphData struct {
	Node NodeData
	Edge EdgeData
}

func TraverseWithBodiesFrom

func TraverseWithBodiesFrom(source string, traversal string, database ...string) ([]GraphData, error)

func TraverseWithBodiesFromTo

func TraverseWithBodiesFromTo(source string, target string, traversal string, database ...string) ([]GraphData, error)

type NodeData

type NodeData struct {
	Identifier interface{} `json:"id"`
	Body       interface{}
}

type SearchQuery

type SearchQuery struct {
	ResultColumn  string
	Key           string
	Tree          bool
	SearchClauses []string
}

type Traversal

type Traversal struct {
	WithBodies bool
	Inbound    bool
	Outbound   bool
}

type WhereClause

type WhereClause struct {
	AndOr     string
	IdLookup  bool
	KeyValue  bool
	Key       string
	Tree      bool
	Predicate string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL