Documentation
¶
Overview ¶
@index GORM-based graph repository that manages CRUD operations and transactions for nodes, edges, and annotations.
Index ¶
- type Store
- func (s *Store) AutoMigrate() error
- func (s *Store) DeleteEdgesByFile(ctx context.Context, filePath string) error
- func (s *Store) DeleteGraph(ctx context.Context) error
- func (s *Store) DeleteNodesByFile(ctx context.Context, filePath string) error
- func (s *Store) GetAnnotation(ctx context.Context, nodeID uint) (*model.Annotation, error)
- func (s *Store) GetEdgesFrom(ctx context.Context, nodeID uint) ([]model.Edge, error)
- func (s *Store) GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]model.Edge, error)
- func (s *Store) GetEdgesTo(ctx context.Context, nodeID uint) ([]model.Edge, error)
- func (s *Store) GetEdgesToNodes(ctx context.Context, nodeIDs []uint) ([]model.Edge, error)
- func (s *Store) GetFileNodesByPathSuffix(ctx context.Context, suffix string) ([]model.Node, error)
- func (s *Store) GetNode(ctx context.Context, qualifiedName string) (*model.Node, error)
- func (s *Store) GetNodeByID(ctx context.Context, id uint) (*model.Node, error)
- func (s *Store) GetNodesByFile(ctx context.Context, filePath string) ([]model.Node, error)
- func (s *Store) GetNodesByFiles(ctx context.Context, filePaths []string) (map[string][]model.Node, error)
- func (s *Store) GetNodesByIDs(ctx context.Context, ids []uint) ([]model.Node, error)
- func (s *Store) GetNodesByQualifiedNames(ctx context.Context, names []string) (map[string][]model.Node, error)
- func (s *Store) UpsertAnnotation(ctx context.Context, ann *model.Annotation) error
- func (s *Store) UpsertEdges(ctx context.Context, edges []model.Edge) error
- func (s *Store) UpsertNodes(ctx context.Context, nodes []model.Node) error
- func (s *Store) WithTx(ctx context.Context, fn func(store store.GraphStore) error) error
- func (s *Store) WithTxDB(ctx context.Context, fn func(store.GraphStore, *gorm.DB) error) error
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 ¶
New creates a repository wrapping a GORM DB. @intent initialize the GraphStore implementation with the injected DB handle.
func (*Store) AutoMigrate ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetEdgesFrom retrieves outgoing edges from a node. @intent load outbound relationships for a specific declaration.
func (*Store) GetEdgesFromNodes ¶
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 ¶
GetEdgesTo retrieves incoming edges to a node. @intent load inbound relationships for a specific declaration.
func (*Store) GetEdgesToNodes ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.