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: GPL-3.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a requested record does not exist.

Functions

func Float32ToBlob

func Float32ToBlob(v []float32) []byte

Float32ToBlob serialises a float32 slice as little-endian bytes for sqlite-vec. Exported so the search package can use it for query vectors too.

Types

type Page

type Page struct {
	ID       int64
	SourceID int64
	URL      string
	Title    string
	Content  string
	Path     []string
}

Page represents an indexed documentation page.

type Source

type Source struct {
	ID            int64
	Name          string
	Type          string
	URL           string
	Repo          string
	Branch        string
	BaseURL       string
	SpaceKey      string
	Auth          string `json:"-"`
	CrawlSchedule string
	LastCrawled   *time.Time
	PageCount     int
	CrawlTotal    int
	IncludePath   string
}

Source represents a configured documentation source.

type Store

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

Store wraps a SQLite database and exposes DocuMcp data operations.

func Open

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

Open opens (or creates) a SQLite database at dsn and applies the schema.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) DB

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

DB returns the underlying *sql.DB for packages that need direct access (e.g. search).

func (*Store) DeleteSource

func (s *Store) DeleteSource(id int64) error

DeleteSource deletes a source and all its pages (cascade).

func (*Store) DeleteToken

func (s *Store) DeleteToken(sourceID int64, provider string) error

DeleteToken removes the stored token for the given source+provider pair. Returns nil if the token did not exist.

func (*Store) GetPageByURL

func (s *Store) GetPageByURL(url string) (*Page, error)

GetPageByURL returns a page by its URL.

func (*Store) GetSource

func (s *Store) GetSource(id int64) (*Source, error)

GetSource returns a single source by ID.

func (*Store) GetSourceIDByName

func (s *Store) GetSourceIDByName(name string) (int64, error)

GetSourceIDByName returns the ID of a source with the given name.

func (*Store) GetToken

func (s *Store) GetToken(sourceID int64, provider string) ([]byte, error)

GetToken retrieves encrypted token data for a source+provider pair. Returns ErrNotFound if no token exists for the given source+provider.

func (*Store) InsertSource

func (s *Store) InsertSource(src Source) (int64, error)

InsertSource inserts a new source and returns its ID.

func (*Store) ListSources

func (s *Store) ListSources() ([]Source, error)

ListSources returns all configured sources.

func (*Store) UpdateSourceCrawlTotal

func (s *Store) UpdateSourceCrawlTotal(id int64, total int) error

UpdateSourceCrawlTotal sets the total number of URLs discovered for a crawl run.

func (*Store) UpdateSourcePageCount

func (s *Store) UpdateSourcePageCount(id int64, count int) error

UpdateSourcePageCount updates the page_count for a source.

func (*Store) UpsertEmbedding

func (s *Store) UpsertEmbedding(pageID int64, embedding []float32) error

UpsertEmbedding inserts or replaces the embedding vector for a page. sqlite-vec vec0 virtual tables do not support INSERT OR REPLACE, so we delete any existing row first and then insert.

func (*Store) UpsertPage

func (s *Store) UpsertPage(p Page) (int64, error)

UpsertPage inserts or updates a page by URL and returns the page's row ID.

func (*Store) UpsertToken

func (s *Store) UpsertToken(sourceID int64, provider string, data []byte, expiresAt time.Time) error

UpsertToken stores encrypted token data for a source+provider pair.

Jump to

Keyboard shortcuts

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