gormstore

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

@index GORM-based graph repository that manages CRUD operations and transactions for nodes, edges, and annotations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is the GORM-backed GraphStore implementation. @intent implement the graph repository contract through a GORM DB handle.

func New

func New(db *gorm.DB) *Store

New creates a repository wrapping a GORM DB. @intent initialize the GraphStore implementation with the injected DB handle.

func (*Store) AutoMigrate

func (s *Store) AutoMigrate() error

AutoMigrate creates or updates the graph repository schema. @intent prepare the GORM model tables required for graph persistence. @sideEffect may modify the database schema.

func (*Store) DeleteEdgesByFile

func (s *Store) DeleteEdgesByFile(ctx context.Context, filePath string) error

DeleteEdgesByFile removes edges generated from a file. @intent selectively clean existing relationships during file-scoped updates. @sideEffect deletes matching file_path records from the edges table.

func (*Store) DeleteGraph

func (s *Store) DeleteGraph(ctx context.Context) error

DeleteGraph removes the entire graph state for the current namespace. @intent replace namespace-scoped state before a full rebuild or include_paths rebuild. @sideEffect deletes all nodes, edges, annotations, and doc_tags in the namespace.

func (*Store) DeleteNodesByFile

func (s *Store) DeleteNodesByFile(ctx context.Context, filePath string) error

DeleteNodesByFile removes nodes in a file and their related data. @intent clean out prior nodes, edges, and annotations before reparsing a file. @sideEffect deletes related records from the nodes, edges, annotations, and doc_tags tables. @domainRule connected edges and annotations must also be removed when deleting a file.

func (*Store) GetAnnotation

func (s *Store) GetAnnotation(ctx context.Context, nodeID uint) (*model.Annotation, error)

GetAnnotation retrieves the annotation attached to a node ID. @intent load a node's structured comment and tags together for search and display. @return returns nil when no annotation exists.

func (*Store) GetEdgesFrom

func (s *Store) GetEdgesFrom(ctx context.Context, nodeID uint) ([]model.Edge, error)

GetEdgesFrom retrieves outgoing edges from a node. @intent load outbound relationships for a specific declaration.

func (*Store) GetEdgesFromNodes

func (s *Store) GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]model.Edge, error)

GetEdgesFromNodes retrieves outgoing edges from multiple nodes. @intent load outbound relationships for multiple declarations in one call. @return returns a nil slice when nodeIDs is empty.

func (*Store) GetEdgesTo

func (s *Store) GetEdgesTo(ctx context.Context, nodeID uint) ([]model.Edge, error)

GetEdgesTo retrieves incoming edges to a node. @intent load inbound relationships for a specific declaration.

func (*Store) GetEdgesToNodes

func (s *Store) GetEdgesToNodes(ctx context.Context, nodeIDs []uint) ([]model.Edge, error)

GetEdgesToNodes retrieves incoming edges to multiple nodes. @intent load inbound relationships for multiple declarations in one call. @return returns a nil slice when nodeIDs is empty.

func (*Store) GetFileNodesByPathSuffix

func (s *Store) GetFileNodesByPathSuffix(ctx context.Context, suffix string) ([]model.Node, error)

GetFileNodesByPathSuffix finds file nodes whose directory matches an import-path suffix. @intent let import edge resolution bind repo-local import paths back to stored file nodes.

func (*Store) GetNode

func (s *Store) GetNode(ctx context.Context, qualifiedName string) (*model.Node, error)

GetNode retrieves a single node by qualified name. @intent find one node by the declaration's qualified name. @return returns nil when no node exists.

func (*Store) GetNodeByID

func (s *Store) GetNodeByID(ctx context.Context, id uint) (*model.Node, error)

GetNodeByID retrieves a single node by primary key. @intent find one node by its internal identifier. @return returns nil when no node exists.

func (*Store) GetNodesByFile

func (s *Store) GetNodesByFile(ctx context.Context, filePath string) ([]model.Node, error)

GetNodesByFile retrieves nodes belonging to a file path. @intent load declarations parsed from a specific source file.

func (*Store) GetNodesByFiles

func (s *Store) GetNodesByFiles(ctx context.Context, filePaths []string) (map[string][]model.Node, error)

GetNodesByFiles retrieves nodes from multiple files grouped by file path. @intent return declarations for a file set grouped by path. @return returns a map whose keys are file paths and values are the nodes in each file.

func (*Store) GetNodesByIDs

func (s *Store) GetNodesByIDs(ctx context.Context, ids []uint) ([]model.Node, error)

GetNodesByIDs retrieves nodes matching the provided ID list. @intent load multiple nodes at once by internal identifier. @return returns a nil slice when ids is empty.

func (*Store) GetNodesByQualifiedNames

func (s *Store) GetNodesByQualifiedNames(ctx context.Context, names []string) (map[string][]model.Node, error)

GetNodesByQualifiedNames loads a set of names into a node map. @intent build a fast lookup map for qualified-name-based reference resolution. @return returns a map keyed by QualifiedName, with slices containing all nodes for each name.

func (*Store) UpsertAnnotation

func (s *Store) UpsertAnnotation(ctx context.Context, ann *model.Annotation) error

UpsertAnnotation stores a node's annotation and tags. @intent replace structured comments for each node with the latest state. @sideEffect performs inserts, updates, and deletes on the annotations and doc_tags tables. @mutates may overwrite ann.ID with the existing record ID. @domainRule only one annotation must be kept per node_id.

func (*Store) UpsertEdges

func (s *Store) UpsertEdges(ctx context.Context, edges []model.Edge) error

UpsertEdges stores a batch of edges keyed by fingerprint. @intent apply graph relationships in bulk without duplicates. @sideEffect performs batch inserts on the edges table. @domainRule edges with the same fingerprint must be stored only once.

func (*Store) UpsertNodes

func (s *Store) UpsertNodes(ctx context.Context, nodes []model.Node) error

UpsertNodes stores a batch of nodes keyed by qualified_name. @intent apply parsed result nodes in bulk without creating duplicates. @sideEffect performs batch inserts and updates on the nodes table. @requires nodes must have a non-empty QualifiedName. @ensures existing nodes with the same qualified_name are updated with the latest metadata.

func (*Store) WithTx

func (s *Store) WithTx(ctx context.Context, fn func(store store.GraphStore) error) error

WithTx executes the given function inside the same transaction. @intent allow multiple repository operations to run atomically as one unit. @sideEffect starts a database transaction and commits or rolls it back. @ensures commits the transaction when fn returns a nil error.

func (*Store) WithTxDB

func (s *Store) WithTxDB(ctx context.Context, fn func(store.GraphStore, *gorm.DB) error) error

WithTxDB passes the transaction DB handle together with the repository. @intent let graph persistence and DB-backed derived-state updates share a single transaction. @sideEffect starts a database transaction and commits or rolls it back.

Jump to

Keyboard shortcuts

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