Documentation ¶
Index ¶
- Variables
- type Config
- type Store
- func (s *Store[K, T]) AddEdge(sourceHash, targetHash K, edge graph.Edge[K]) error
- func (s *Store[K, T]) AddVertex(hash K, value T, properties graph.VertexProperties) error
- func (s *Store[K, T]) Edge(sourceHash, targetHash K) (graph.Edge[K], error)
- func (s *Store[K, T]) ListEdges() ([]graph.Edge[K], error)
- func (s *Store[K, T]) ListVertices() ([]K, error)
- func (s *Store[K, T]) RemoveEdge(sourceHash, targetHash K) error
- func (s *Store[K, T]) SetupTables() error
- func (s *Store[K, T]) Vertex(hash K) (T, graph.VertexProperties, error)
- func (s *Store[K, T]) VertexCount() (int, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
VerticesTable: "vertices",
EdgesTable: "edges",
VertexHashType: "TEXT",
VertexValueType: "JSON",
}
DefaultConfig is a sane default configuration of the table schema. Using DefaultConfig when creating a store using New makes sense for most users.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { VerticesTable string EdgesTable string VertexHashType string VertexValueType string }
Config configures the table schema, i.e. the table names and some data types of its columns.
type Store ¶
type Store[K comparable, T any] struct { // contains filtered or unexported fields }
Store is a graph.Store implementation that uses an SQL database to store and retrieve graphs.
func New ¶
New creates a new SQL store that can be passed to graph.NewWithStore. It expects a database connection directly to the actual database schema in the form of a sql.DB instance.
func (*Store[K, T]) AddVertex ¶
func (s *Store[K, T]) AddVertex(hash K, value T, properties graph.VertexProperties) error
AddVertex implements graph.Store.AddVertex.
func (*Store[K, T]) ListVertices ¶
ListVertices implements graph.Store.ListVertices.
func (*Store[K, T]) RemoveEdge ¶
RemoveEdge implements graph.Store.RemoveEdge.
func (*Store[K, T]) SetupTables ¶
SetupTables creates all required tables inside the configured database. The schema is documented in this library's README file.
func (*Store[K, T]) Vertex ¶
func (s *Store[K, T]) Vertex(hash K) (T, graph.VertexProperties, error)
Vertex implements graph.Store.Vertex.
func (*Store[K, T]) VertexCount ¶
VertexCount implements graph.Store.VertexCount.