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]) DestroyTables() error
- func (s *Store[K, T]) Edge(sourceHash, targetHash K) (graph.Edge[K], error)
- func (s *Store[K, T]) EdgeCount() (int, 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]) RemoveVertex(hash K) error
- func (s *Store[K, T]) SetupTables() error
- func (s *Store[K, T]) UpdateEdge(sourceHash, targetHash K, edge graph.Edge[K]) 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", Safe: false, Unique: false, }
DefaultConfig is a sane default configuration of the table schema. Using DefaultConfig when creating a store using New makes sense for most users.
var SafeConfig = Config{ VerticesTable: "vertices", EdgesTable: "edges", VertexHashType: "TEXT", VertexValueType: "JSON", Safe: true, Unique: true, }
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { VerticesTable string EdgesTable string VertexHashType string VertexValueType string Safe bool Unique bool }
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]) DestroyTables ¶
DestroyTables drops all tables and thus removes all data from the database.
func (*Store[K, T]) ListVertices ¶
ListVertices implements graph.Store.ListVertices.
func (*Store[K, T]) RemoveEdge ¶
RemoveEdge implements graph.Store.RemoveEdge.
func (*Store[K, T]) RemoveVertex ¶
RemoveVertex implements graph.Store.RemoveVertex. from https://github.com/dominikbraun/graph-sql/pull/3/files
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]) UpdateEdge ¶
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.