store

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Overview

Package store owns the SQLite database: connection, schema migration, project lifecycle, and a Writer that persists what indexers extract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProjectInfo

type ProjectInfo struct {
	Name      string
	Root      string
	VcsRev    string
	IndexedAt time.Time
	Symbols   int
	Edges     int
	Files     int
}

ProjectInfo summarizes one indexed repo.

type Store

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

Store is a handle to the codenav database.

func Open

func Open(path string) (*Store, error)

Open opens (creating if needed) the database at path and applies the schema. PRAGMAs are passed in the DSN so every connection inherits them; a single open connection keeps WAL writes simple for a CLI.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB exposes the underlying handle for read-side packages (query, graph).

func (*Store) DeleteProject

func (s *Store) DeleteProject(name string) error

DeleteProject removes a project and all its rows (incl. FTS, which is not covered by foreign-key cascades because the FTS tables are virtual).

func (*Store) ListProjects

func (s *Store) ListProjects() ([]ProjectInfo, error)

ListProjects returns all indexed projects with counts.

func (*Store) NewWriter

func (s *Store) NewWriter(project, root string) (*Writer, error)

NewWriter starts a fresh index of project at root. Any prior data for the project is removed first (M1 does full re-index).

func (*Store) ProjectSig

func (s *Store) ProjectSig(name string) (string, error)

ProjectSig returns the stored source signature for a project, or "" if the project is not indexed.

func (*Store) SetProjectSig

func (s *Store) SetProjectSig(name, sig string) error

SetProjectSig records the source signature after a successful index.

type Writer

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

Writer persists one indexing run for a single project inside a transaction. References, edges and routes are buffered and resolved at Commit, once every symbol's id is known (definitions may appear after their use sites).

Writer implements index.Sink.

func (*Writer) Commit

func (w *Writer) Commit(vcsRev string) error

Commit resolves buffered references/edges/routes against the symbol table and finalizes the transaction.

func (*Writer) Edge

func (w *Writer) Edge(e index.Edge) error

Edge buffers a relationship for commit-time resolution.

func (*Writer) File

func (w *Writer) File(f index.FileRec) error

File records file metadata and indexes the file body for code search.

func (*Writer) Reference

func (w *Writer) Reference(r index.Reference) error

Reference buffers a use-site for commit-time resolution.

func (*Writer) Rollback

func (w *Writer) Rollback() error

Rollback aborts the indexing transaction.

func (*Writer) Route

func (w *Writer) Route(r index.Route) error

Route buffers a route for commit-time resolution.

func (*Writer) Symbol

func (w *Writer) Symbol(sym index.Symbol) error

Symbol inserts a definition and makes it searchable.

Jump to

Keyboard shortcuts

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