sqlite

package
v0.0.0-...-10ffa72 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInTx = errors.New("already in transaction")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps a SQLite database connection.

func Open

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

Open opens the SQLite database at the given path, creating it if necessary, and runs any pending migrations.

func (*DB) Close

func (d *DB) Close() error

Close closes the database connection.

func (*DB) CompleteProject

func (d *DB) CompleteProject(ctx context.Context, id int64, cascade bool, at time.Time) (gtd.Project, error)

func (*DB) CompleteTask

func (d *DB) CompleteTask(ctx context.Context, id int64, at time.Time) (gtd.Task, error)

func (*DB) CountTasksByProjects

func (d *DB) CountTasksByProjects(ctx context.Context, projectIDs []int64) (map[int64]gtd.ProjectTaskCounts, error)

func (*DB) CreateItem

func (d *DB) CreateItem(ctx context.Context, item gtd.Item) (gtd.Item, error)

CreateItem inserts a fresh inbox capture. Clarify pointers and the discarded flag are not accepted on create — items start in the inbox unconditionally and reach terminal state only via the service-layer clarify operations.

func (*DB) CreateProject

func (d *DB) CreateProject(ctx context.Context, project gtd.Project) (gtd.Project, error)

func (*DB) CreateTask

func (d *DB) CreateTask(ctx context.Context, task gtd.Task) (gtd.Task, error)

func (*DB) DeleteTask

func (d *DB) DeleteTask(ctx context.Context, id int64) error

func (*DB) DropProject

func (d *DB) DropProject(ctx context.Context, id int64, cascade bool, at time.Time) (gtd.Project, error)

func (*DB) DropTask

func (d *DB) DropTask(ctx context.Context, id int64, at time.Time) (gtd.Task, error)

func (*DB) GetItem

func (d *DB) GetItem(ctx context.Context, id int64) (gtd.Item, error)

func (*DB) GetProject

func (d *DB) GetProject(ctx context.Context, id int64) (gtd.Project, error)

func (*DB) GetTask

func (d *DB) GetTask(ctx context.Context, id int64) (gtd.Task, error)

func (*DB) ListItems

func (d *DB) ListItems(ctx context.Context) ([]gtd.Item, error)

ListItems returns inbox items that have not been clarified or discarded, ordered by created_at ASC (FIFO).

func (*DB) ListProjects

func (d *DB) ListProjects(ctx context.Context, filter gtd.ProjectFilter) ([]gtd.Project, error)

func (*DB) ListTasks

func (d *DB) ListTasks(ctx context.Context, filter gtd.TaskFilter) ([]gtd.Task, error)

func (*DB) MoveProjectDown

func (d *DB) MoveProjectDown(ctx context.Context, id int64, filter gtd.ProjectFilter) error

MoveProjectDown shifts the project one slot later within projects of the same status that match filter. No-op when already at the bottom of the filtered set.

func (*DB) MoveProjectUp

func (d *DB) MoveProjectUp(ctx context.Context, id int64, filter gtd.ProjectFilter) error

MoveProjectUp shifts the project one slot earlier within projects of the same status that match filter. No-op when already at the top of the filtered set.

func (*DB) MoveTaskDown

func (d *DB) MoveTaskDown(ctx context.Context, id int64, filter gtd.TaskFilter) error

MoveTaskDown shifts the task one slot later within the open tasks matching filter. No-op when already at the bottom of the filtered set.

func (*DB) MoveTaskUp

func (d *DB) MoveTaskUp(ctx context.Context, id int64, filter gtd.TaskFilter) error

MoveTaskUp shifts the task one slot earlier within the open tasks matching filter. No-op when already at the top of the filtered set.

func (*DB) ParkProject

func (d *DB) ParkProject(ctx context.Context, id int64, at time.Time) (gtd.Project, error)

func (*DB) ReopenProject

func (d *DB) ReopenProject(ctx context.Context, id int64, at time.Time) (gtd.Project, error)

func (*DB) ReopenTask

func (d *DB) ReopenTask(ctx context.Context, id int64, at time.Time) (gtd.Task, error)

func (*DB) RunTx

func (d *DB) RunTx(ctx context.Context, f func(context.Context, *DB) error) (err error)

func (*DB) UpdateItemClarifiedIntoProject

func (d *DB) UpdateItemClarifiedIntoProject(ctx context.Context, id, projectID int64) (gtd.Item, error)

UpdateItemClarifiedIntoProject stamps the item's ClarifiedIntoProjectID (used by both Incubate and ClarifyAsProject) and returns the resulting row.

func (*DB) UpdateItemClarifiedIntoTask

func (d *DB) UpdateItemClarifiedIntoTask(ctx context.Context, id, taskID int64) (gtd.Item, error)

UpdateItemClarifiedIntoTask stamps the item's ClarifiedIntoTaskID and returns the resulting row. The caller is responsible for transaction wrapping and pre-checks; the underlying CHECK constraint enforces mutual exclusion as a safety net.

func (*DB) UpdateItemDiscarded

func (d *DB) UpdateItemDiscarded(ctx context.Context, id int64) (gtd.Item, error)

UpdateItemDiscarded marks an item as discarded and returns the resulting row.

func (*DB) UpdateProject

func (d *DB) UpdateProject(ctx context.Context, project gtd.Project) (gtd.Project, error)

func (*DB) UpdateTask

func (d *DB) UpdateTask(ctx context.Context, task gtd.Task) (gtd.Task, error)

type QueryContext

type QueryContext interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
}

Jump to

Keyboard shortcuts

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