db

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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
	CreatedAt time.Time
}

Account represents a stored Audiobookshelf server account.

type ListeningSession

type ListeningSession struct {
	ItemID    string
	EpisodeID string
}

ListeningSession is the item or the podcast episode that played last. At startup, pine loads it again at the position on the server.

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. A database of an earlier pine can have more accounts, which are not the default.

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 and makes it the default. It deletes each other account in the same transaction, so that the database keeps no token of an earlier login.

func (*Store) SaveListeningSession

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

SaveListeningSession stores the item or the episode that plays. Only one session is kept at a time (the most recent), enabling crash recovery. It stores no session ID and no position: pine does not read them, and the ID of a play session is a secret.

Jump to

Keyboard shortcuts

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