db

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 7 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

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        string
	ServerURL string
	Username  string
	Token     string
	IsDefault bool
	CreatedAt time.Time
}

Account represents a stored Audiobookshelf server account.

type ListeningSession

type ListeningSession struct {
	ItemID      string
	EpisodeID   string
	SessionID   string
	CurrentTime float64
	Duration    float64
	CreatedAt   time.Time
}

ListeningSession represents the last active playback state for crash recovery.

type Store

type Store struct {
	DB *sql.DB
}

Store wraps the SQLite database connection.

func Open

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

Open opens (or creates) a SQLite database at path and runs migrations.

func (*Store) ClearSession

func (s *Store) ClearSession() error

ClearSession removes all saved listening sessions.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection.

func (*Store) GetDefaultAccount

func (s *Store) GetDefaultAccount() (Account, error)

GetDefaultAccount returns the account marked as default. Returns an error if no default account is set.

func (*Store) GetLastSession

func (s *Store) GetLastSession() (ListeningSession, error)

GetLastSession retrieves the last saved playback session. Returns an error if no session has been saved.

func (*Store) SaveAccount

func (s *Store) SaveAccount(a Account) error

SaveAccount inserts or updates an account. If it's the first account, it becomes the default automatically. When the saved account is (or becomes) the default, any other accounts are unset as default atomically within a transaction so that only one default can exist at a time.

func (*Store) SaveListeningSession

func (s *Store) SaveListeningSession(session ListeningSession) error

SaveListeningSession stores the current playback state. Only one session is kept at a time (the most recent), enabling crash recovery.

Jump to

Keyboard shortcuts

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