db

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB wraps the SQLite database connection

func Open

func Open(dataDir string) (*DB, error)

Open opens or creates the ccvault database

func (*DB) BeginTx

func (db *DB) BeginTx() (*sql.Tx, error)

BeginTx starts a new transaction

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) DeleteToolUsesForSessionTx

func (db *DB) DeleteToolUsesForSessionTx(tx *sql.Tx, sessionID string) error

DeleteToolUsesForSession removes tool uses for a session

func (*DB) DeleteTurnsForSession

func (db *DB) DeleteTurnsForSession(sessionID string) error

DeleteTurnsForSession removes all turns for a session (for re-sync)

func (*DB) DeleteTurnsForSessionTx

func (db *DB) DeleteTurnsForSessionTx(tx *sql.Tx, sessionID string) error

DeleteTurnsForSessionTx removes all turns for a session within a transaction

func (*DB) GetAllSourceMtimes

func (db *DB) GetAllSourceMtimes() (map[string]time.Time, error)

GetAllSourceMtimes loads all source file modification times from the source_files tracking table

func (*DB) GetFirstAndLastActivity

func (db *DB) GetFirstAndLastActivity() (first, last time.Time, err error)

GetFirstAndLastActivity returns the date range of all activity

func (*DB) GetProject

func (db *DB) GetProject(id int64) (*models.Project, error)

GetProject retrieves a project by ID

func (*DB) GetProjectByPath

func (db *DB) GetProjectByPath(path string) (*models.Project, error)

GetProjectByPath retrieves a project by path

func (*DB) GetProjectStats

func (db *DB) GetProjectStats() (count int, totalTokens int64, err error)

GetProjectStats returns aggregate statistics for projects

func (*DB) GetProjects

func (db *DB) GetProjects(orderBy string, limit int) ([]models.Project, error)

GetProjects retrieves all projects

func (*DB) GetSession

func (db *DB) GetSession(id string) (*models.Session, error)

GetSession retrieves a session by ID

func (*DB) GetSessionBySourceFile

func (db *DB) GetSessionBySourceFile(path string) (*models.Session, error)

GetSessionBySourceFile retrieves a session by its source file path

func (*DB) GetSessionStats

func (db *DB) GetSessionStats() (count int, totalTurns int, totalTokens int64, err error)

GetSessionStats returns aggregate statistics for sessions

func (*DB) GetSessions

func (db *DB) GetSessions(projectID int64, limit int) ([]models.Session, error)

GetSessions retrieves sessions with optional filters

func (*DB) GetSourceMtime

func (db *DB) GetSourceMtime(path string) (time.Time, error)

GetSourceMtime retrieves the last sync time for a source file

func (*DB) GetTokensByModel

func (db *DB) GetTokensByModel() (map[string]int64, error)

GetTokensByModel returns token usage grouped by model

func (*DB) GetToolUsageStats

func (db *DB) GetToolUsageStats(limit int) (map[string]int, error)

GetToolUsageStats returns tool usage counts

func (*DB) GetTurnCount

func (db *DB) GetTurnCount() (int, error)

GetTurnCount returns total number of turns

func (*DB) GetTurns

func (db *DB) GetTurns(sessionID string) ([]models.Turn, error)

GetTurns retrieves turns for a session

func (*DB) InsertToolUses

func (db *DB) InsertToolUses(toolUses []models.ToolUse) error

InsertToolUses inserts tool usage records

func (*DB) InsertToolUsesTx

func (db *DB) InsertToolUsesTx(tx *sql.Tx, toolUses []models.ToolUse) error

InsertToolUsesTx inserts tool usage records within a transaction

func (*DB) InsertTurns

func (db *DB) InsertTurns(turns []models.Turn) error

InsertTurns inserts multiple turns in a batch

func (*DB) InsertTurnsTx

func (db *DB) InsertTurnsTx(tx *sql.Tx, turns []models.Turn) error

InsertTurnsTx inserts multiple turns within a transaction

func (*DB) Path

func (db *DB) Path() string

Path returns the database file path

func (*DB) SearchTurns

func (db *DB) SearchTurns(query string, limit int) ([]models.Turn, error)

SearchTurns performs full-text search on turn content

func (*DB) SearchTurnsWithFilters

func (db *DB) SearchTurnsWithFilters(textQuery string, projectID int64, model string, toolName string, limit int) ([]models.Turn, error)

SearchTurnsWithFilters performs filtered search

func (*DB) UpdateProjectStats

func (db *DB) UpdateProjectStats(projectID int64) error

UpdateProjectStats recalculates project statistics from sessions

func (*DB) UpsertProject

func (db *DB) UpsertProject(p *models.Project) error

UpsertProject creates or updates a project record

func (*DB) UpsertProjectTx

func (db *DB) UpsertProjectTx(tx *sql.Tx, p *models.Project) error

UpsertProjectTx creates or updates a project record within a transaction

func (*DB) UpsertSession

func (db *DB) UpsertSession(s *models.Session) error

UpsertSession creates or updates a session record

func (*DB) UpsertSessionTx

func (db *DB) UpsertSessionTx(tx *sql.Tx, s *models.Session) error

UpsertSessionTx creates or updates a session record within a transaction

func (*DB) UpsertSourceFileMtime

func (db *DB) UpsertSourceFileMtime(path string, mtime time.Time) error

UpsertSourceFileMtime records a source file's mtime after processing

func (*DB) UpsertSourceFileMtimeTx

func (db *DB) UpsertSourceFileMtimeTx(tx *sql.Tx, path string, mtime time.Time) error

UpsertSourceFileMtimeTx records a source file's mtime within a transaction

func (*DB) WithTx

func (db *DB) WithTx(fn func(*sql.Tx) error) error

WithTx executes a function within a transaction

Jump to

Keyboard shortcuts

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