store

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package store connects to the data store and manages timers and sessions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*bolt.DB
}

Client is a BoltDB database client.

func NewClient

func NewClient(dbFilePath string) (*Client, error)

NewClient returns a wrapper to a BoltDB connection.

func (*Client) DeleteAllTimers added in v1.4.0

func (c *Client) DeleteAllTimers() error

func (*Client) DeleteSessions

func (c *Client) DeleteSessions(startTimes []time.Time) error

func (*Client) DeleteTimer

func (c *Client) DeleteTimer(startTime time.Time) error

func (*Client) GetSession added in v1.4.0

func (c *Client) GetSession(
	startTime time.Time,
) (*models.Session, error)

func (*Client) GetSessions

func (c *Client) GetSessions(
	since, until time.Time,
	tags []string,
) ([]*models.Session, error)

func (*Client) Open

func (c *Client) Open() error

func (*Client) RetrievePausedTimers added in v1.4.0

func (c *Client) RetrievePausedTimers() ([]*models.Timer, error)

func (*Client) UpdateSessions added in v1.4.0

func (c *Client) UpdateSessions(sessions map[time.Time]*models.Session) error

func (*Client) UpdateTimer added in v1.4.0

func (c *Client) UpdateTimer(timer *models.Timer) error

type DB

type DB interface {
	RetrievePausedTimers() ([]*models.Timer, error)
	// GetSessions returns saved sessions according to the specified time and tag
	// constraints
	GetSessions(
		since, until time.Time,
		tags []string,
	) ([]*models.Session, error)
	// UpdateSessions updates one or more Focus sessions.
	// Each session is created if it doesn't
	// exist already, or overwritten if it does.
	UpdateSessions(map[time.Time]*models.Session) error
	// DeleteSessions deletes one or more saved sessions
	DeleteSessions(startTimes []time.Time) error
	// GetSession returns a previously created session. If the session does not
	// exist, no error is returned.
	GetSession(
		startTime time.Time,
	) (sess *models.Session, err error)
	// UpdateTimer stores a timer and the key of an interrupted session
	UpdateTimer(timer *models.Timer) error
	// DeleteTimer deletes a previously saved timer if it exists
	DeleteTimer(startTime time.Time) error
	// DeleteAllTimers deletes all the saved timers in the database
	DeleteAllTimers() error
	// Close ends the database connection
	Close() error
	// Open initiates a database connection
	Open() error
}

DB is the database storage interface.

Jump to

Keyboard shortcuts

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