db

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalTargets

func MarshalTargets(names []string) string

MarshalTargets serialises a slice of entity/relation names to a JSON string.

func OpenDB

func OpenDB(dbURL string) (*gorm.DB, error)

OpenDB opens the database and runs AutoMigrate for all models. dbURL accepts: "sqlite://path.db", "postgres://...", a plain file path, or "" for in-memory SQLite.

Types

type ContentCache

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

func NewContentCache

func NewContentCache(db *gorm.DB, enabled bool, maxSize int) *ContentCache

func (*ContentCache) Count

func (cc *ContentCache) Count() (int64, error)

func (*ContentCache) DeleteOrphanedContent

func (cc *ContentCache) DeleteOrphanedContent(activeRepos []string) error

func (*ContentCache) ListDocs

func (cc *ContentCache) ListDocs(repoName string) ([]corecontent.DocRecord, error)

func (*ContentCache) NeedsUpdate

func (cc *ContentCache) NeedsUpdate(repoName, path, sha string) bool

func (*ContentCache) Search

func (cc *ContentCache) Search(query, repoName, fileType string) ([]corecontent.ContentMatch, error)

func (*ContentCache) SearchMode

func (cc *ContentCache) SearchMode() string

func (*ContentCache) Upsert

func (cc *ContentCache) Upsert(repoName, path, sha, content, fileType string) error

type DBAuditStore

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

DBAuditStore is the SQLite/Postgres implementation of coreaudit.AuditStore.

func NewAuditStore

func NewAuditStore(db *gorm.DB) (*DBAuditStore, error)

NewAuditStore creates the audit_events table (if absent) and returns a store.

func (*DBAuditStore) Query

Query retrieves audit events matching the filter. Returns the page and total count.

func (*DBAuditStore) Summary

Summary returns anomaly-focused metrics over the given rolling window.

func (*DBAuditStore) Write

Write persists one audit event. A UUIDv7 primary key is generated here so ORDER BY id gives chronological order without an extra index.

type GraphRepo

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

GraphRepo is the GORM implementation of core/graph.GraphRepository.

func NewGraphRepo

func NewGraphRepo(db *gorm.DB) *GraphRepo

NewGraphRepo creates a GraphRepo backed by db.

func (*GraphRepo) AddObservations

func (r *GraphRepo) AddObservations(observations []coregraph.Observation) ([]coregraph.Observation, error)

func (*GraphRepo) CreateEntities

func (r *GraphRepo) CreateEntities(entities []coregraph.Entity) ([]coregraph.Entity, error)

func (*GraphRepo) CreateRelations

func (r *GraphRepo) CreateRelations(relations []coregraph.Relation) ([]coregraph.Relation, error)

func (*GraphRepo) DeleteEntities

func (r *GraphRepo) DeleteEntities(entityNames []string) error

func (*GraphRepo) DeleteObservations

func (r *GraphRepo) DeleteObservations(deletions []coregraph.Observation) error

func (*GraphRepo) DeleteRelations

func (r *GraphRepo) DeleteRelations(relations []coregraph.Relation) error

func (*GraphRepo) EntityCount

func (r *GraphRepo) EntityCount() (int64, error)

func (*GraphRepo) EntityTypeCounts

func (r *GraphRepo) EntityTypeCounts() (map[string]int64, error)

func (*GraphRepo) FindPath

func (r *GraphRepo) FindPath(from, to string, maxDepth int) ([]coregraph.PathEdge, error)

func (*GraphRepo) GetIntegrationMap

func (r *GraphRepo) GetIntegrationMap(_ context.Context, service string, depth int) (coregraph.IntegrationMap, error)

func (*GraphRepo) ListEntities

func (r *GraphRepo) ListEntities(entityType string) (coregraph.KnowledgeGraph, error)

func (*GraphRepo) ListRelations

func (r *GraphRepo) ListRelations(relationType, fromEntity string) ([]coregraph.Relation, error)

func (*GraphRepo) OpenNodes

func (r *GraphRepo) OpenNodes(names []string) (coregraph.KnowledgeGraph, error)

func (*GraphRepo) OpenNodesFiltered

func (r *GraphRepo) OpenNodesFiltered(names []string, includeArchived bool) (coregraph.KnowledgeGraph, error)

func (*GraphRepo) ReadGraph

func (r *GraphRepo) ReadGraph() (coregraph.KnowledgeGraph, error)

func (*GraphRepo) SearchNodes

func (r *GraphRepo) SearchNodes(query string) (coregraph.KnowledgeGraph, error)

func (*GraphRepo) SearchNodesFiltered

func (r *GraphRepo) SearchNodesFiltered(query string, includeArchived bool) (coregraph.KnowledgeGraph, error)

func (*GraphRepo) TraverseGraph

func (r *GraphRepo) TraverseGraph(entity, relationType, direction string, maxDepth int) ([]coregraph.TraverseNode, []coregraph.TraverseEdge, error)

func (*GraphRepo) UpdateEntity

func (r *GraphRepo) UpdateEntity(oldName, newName, newType string) error

Jump to

Keyboard shortcuts

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