Documentation
¶
Index ¶
- Variables
- func MapGenre(tag string) string
- func Translit(s string) string
- type BatchInserter
- type Repo
- func (r *Repo) Add(record *book.Book) error
- func (r *Repo) AddBatch(records []*book.Book) error
- func (r *Repo) CheckpointWAL() error
- func (r *Repo) Close() error
- func (r *Repo) CreateIndexes() error
- func (r *Repo) DropIndexes() error
- func (r *Repo) GetAuthorByID(id int64) (*book.Author, error)
- func (r *Repo) GetAuthors() ([]book.Author, error)
- func (r *Repo) GetAuthorsByLetter(letters string) ([]book.Author, error)
- func (r *Repo) GetAuthorsWithBookCount() ([]book.AuthorWithBookCount, error)
- func (r *Repo) GetAuthorsWithBookCountByLetter(letters string) ([]book.AuthorWithBookCount, error)
- func (r *Repo) GetBookByID(id int64) (*book.Book, error)
- func (r *Repo) GetBooks() ([]string, error)
- func (r *Repo) GetBooksByAuthorID(id int64) ([]book.Book, error)
- func (r *Repo) GetBooksByGenre(genre string, limit, offset int) ([]book.Book, int, error)
- func (r *Repo) GetBooksByLetter(letters string) ([]book.Book, error)
- func (r *Repo) GetBooksBySeriesID(seriesID int64) ([]book.Book, error)
- func (r *Repo) GetGenres() ([]book.Genre, error)
- func (r *Repo) GetKeywords() ([]book.Keyword, error)
- func (r *Repo) GetLanguages() ([]string, error)
- func (r *Repo) GetRecentBooks(limit, offset int) ([]book.Book, int, error)
- func (r *Repo) GetSeries() ([]book.SeriesInfo, error)
- func (r *Repo) InitCache() error
- func (r *Repo) List() error
- func (r *Repo) NewBatchInserter(tx *sql.Tx) (*BatchInserter, error)
- func (r *Repo) Ping() error
- func (r *Repo) RebuildFTSIndex() error
- func (r *Repo) Search() error
- func (r *Repo) SearchBooks(ctx context.Context, query string, limit, offset int, fields []string, ...) ([]book.BookSearchResult, error)
- func (r *Repo) SetBulkImportMode(enable bool) error
- func (r *Repo) SetFastMode(enable bool) error
- func (r *Repo) SyncGenreDisplayNames()
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when a record is not found in the repository
Functions ¶
Types ¶
type BatchInserter ¶
type BatchInserter struct {
// contains filtered or unexported fields
}
func (*BatchInserter) Close ¶
func (bi *BatchInserter) Close()
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func GetStorage ¶
func (*Repo) CheckpointWAL ¶
CheckpointWAL performs a WAL checkpoint to write all pending changes to the database file Use TRUNCATE mode for maximum efficiency: resets WAL file to zero bytes
func (*Repo) CreateIndexes ¶
func (*Repo) DropIndexes ¶
func (*Repo) GetAuthorsByLetter ¶
func (*Repo) GetAuthorsWithBookCount ¶
func (r *Repo) GetAuthorsWithBookCount() ([]book.AuthorWithBookCount, error)
func (*Repo) GetAuthorsWithBookCountByLetter ¶
func (r *Repo) GetAuthorsWithBookCountByLetter(letters string) ([]book.AuthorWithBookCount, error)
func (*Repo) GetBooksByGenre ¶
GetBooksByGenre returns books by genre with pagination
func (*Repo) GetBooksByLetter ¶
func (*Repo) GetBooksBySeriesID ¶
GetBooksBySeriesID books by series
func (*Repo) GetKeywords ¶
GetKeywords Get all keywords
func (*Repo) GetLanguages ¶ added in v0.1.2
GetLanguages returns a list of distinct languages from non-deleted books
func (*Repo) GetRecentBooks ¶
GetRecentBooks returns recently added books with pagination
func (*Repo) GetSeries ¶
func (r *Repo) GetSeries() ([]book.SeriesInfo, error)
GetSeries Get all series
func (*Repo) NewBatchInserter ¶
func (r *Repo) NewBatchInserter(tx *sql.Tx) (*BatchInserter, error)
func (*Repo) RebuildFTSIndex ¶
RebuildFTSIndex rebuilds the full-text search index for all books Updates the author field in books_fts to include properly concatenated author names
func (*Repo) SearchBooks ¶
func (r *Repo) SearchBooks(ctx context.Context, query string, limit, offset int, fields []string, languages []string) ([]book.BookSearchResult, error)
SearchBooks performs full-text search across book titles and authors Uses FTS5 for fast, ranked search results Optimized with single query including author JOIN (fixes N+1 query issue)
func (*Repo) SetBulkImportMode ¶
SetBulkImportMode configures the database for bulk import operations When enabled: disables WAL auto-checkpoint, increases cache to 256MB When disabled: restores normal checkpoint behavior and cache size
func (*Repo) SetFastMode ¶
func (*Repo) SyncGenreDisplayNames ¶
func (r *Repo) SyncGenreDisplayNames()
type Repository ¶
type Repository interface {
// Close closes the database connection
Close() error
// Health check
Ping() error
// Authors
GetAuthors() ([]book.Author, error)
GetAuthorsByLetter(letters string) ([]book.Author, error)
GetAuthorByID(id int64) (*book.Author, error)
GetAuthorsWithBookCount() ([]book.AuthorWithBookCount, error)
GetAuthorsWithBookCountByLetter(letters string) ([]book.AuthorWithBookCount, error)
// Books
GetBooks() ([]string, error)
GetBooksByLetter(letters string) ([]book.Book, error)
GetBooksByAuthorID(id int64) ([]book.Book, error)
GetBookByID(id int64) (*book.Book, error)
GetRecentBooks(limit, offset int) ([]book.Book, int, error)
GetBooksByGenre(genre string, limit, offset int) ([]book.Book, int, error)
// SearchBooks performs full-text search across books by title and author
// Returns results ranked by relevance (FTS5 rank)
SearchBooks(ctx context.Context, query string, limit, offset int, fields []string, languages []string) ([]book.BookSearchResult, error)
// Genres
GetGenres() ([]book.Genre, error)
// Languages
GetLanguages() ([]string, error)
// Write operations
Add(record *book.Book) error
Search() error
List() error
// RebuildFTSIndex rebuilds the full-text search index for all books
RebuildFTSIndex() error
CreateIndexes() error
DropIndexes() error
InitCache() error
SetFastMode(enable bool) error
// Bulk import optimizations
SetBulkImportMode(enable bool) error
CheckpointWAL() error
}
Repository defines the interface for data access operations