storage

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	URL         string    `json:"url"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Content     string    `json:"content"`
	Checksum    string    `json:"checksum"`
	Embeddings  []float32 `json:"embeddings"`
	Context     string    `json:"context"`
	SourceType  string    `json:"source_type"`
}

Document represents the data to be stored.

type Storage

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

Storage manages the SQLite database.

func NewStorage

func NewStorage(dbPath string) (*Storage, error)

NewStorage creates or opens an SQLite database.

func (*Storage) Clean added in v1.0.13

func (s *Storage) Clean() error

Clean deletes all documents from the database.

func (*Storage) Close

func (s *Storage) Close()

Close closes the database connection.

func (*Storage) DeleteDocumentsByPrefix

func (s *Storage) DeleteDocumentsByPrefix(prefix, context string) error

DeleteDocumentsByPrefix deletes all documents with a URL starting with the given prefix, optionally filtered by context.

func (*Storage) GetContexts added in v1.0.18

func (s *Storage) GetContexts() ([]string, error)

GetContexts retrieves a list of unique contexts from the database.

func (*Storage) GetDB

func (s *Storage) GetDB() *sql.DB

GetDB returns the underlying *sql.DB connection.

func (*Storage) GetDocument

func (s *Storage) GetDocument(url, context string) (*Document, error)

GetDocument retrieves a document by its URL, optionally filtered by context.

func (*Storage) ListAllDocuments added in v1.0.13

func (s *Storage) ListAllDocuments(context string) ([]*Document, error)

ListAllDocuments retrieves all documents from the store, optionally filtered by context.

func (*Storage) ListDocuments

func (s *Storage) ListDocuments(context string, limit int) ([]*Document, error)

ListDocuments retrieves documents from the store, optionally filtered by context, with a limit.

func (*Storage) SearchDocChunks added in v1.0.18

func (s *Storage) SearchDocChunks(query string, context string) ([]*Document, error)

SearchDocChunks searches for documents based on a query and optional context.

func (*Storage) UpsertDocument

func (s *Storage) UpsertDocument(doc *Document) error

UpsertDocument stores a document in the database. The URL is used as the key.

Jump to

Keyboard shortcuts

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