Documentation ¶
Index ¶
- Variables
- type Database
- type SQLiteDatabase
- func (db *SQLiteDatabase) Children(id uuid.UUID) ([]models.Task, error)
- func (db *SQLiteDatabase) Complete(id uuid.UUID) error
- func (db *SQLiteDatabase) Delete(id uuid.UUID) error
- func (db *SQLiteDatabase) Get(id uuid.UUID) (models.Task, error)
- func (db *SQLiteDatabase) GetAll() ([]models.Task, error)
- func (db *SQLiteDatabase) Goals() ([]models.Task, error)
- func (db *SQLiteDatabase) Inbox() ([]models.Task, error)
- func (db *SQLiteDatabase) Link(parentID uuid.UUID, childID uuid.UUID) error
- func (db *SQLiteDatabase) Migrate() error
- func (db *SQLiteDatabase) Todo(id uuid.UUID) ([]models.Task, error)
- func (db *SQLiteDatabase) Unlink(parentID uuid.UUID, childID uuid.UUID) error
- func (db *SQLiteDatabase) Upsert(task models.Task) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidID = errors.New("Task has an invalid ID") ErrMissingTask = errors.New("No such task") ErrTaskCycle = errors.New("A task cycle would be created") )
View Source
var (
ErrFailedToCreate = errors.New("Failed to create database")
)
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { // Children recursively traverses the graph of tasks // and returns all tasks which are the children // of the task belonging to the provided ID. // // If the provided ID is invalid (aka, empty and would produce ""), // this should return `ErrInvalidID`. // // If no such task exists, or that task is already deleted, // this should return `ErrMissingTask`. Children(id uuid.UUID) ([]models.Task, error) // Complete marks the task belonging to the provided ID as complete. // // If the provided ID is invalid (aka, empty and would produce ""), // this should return `ErrInvalidID`. // // If no such task exists, or that task is already deleted, // this should return `ErrMissingTask`. Complete(id uuid.UUID) error // Delete marks the task belonging to the provided ID as deleted. // // If the provided ID is invalid (aka, empty and would produce ""), // this should return `ErrInvalidID`. // // If no such task exists this should return `ErrMissingTask`. Delete(id uuid.UUID) error // Get returns the models.Task belonging to the provided ID. // // If the provided ID is invalid (aka, empty and would produce ""), // this should return `ErrInvalidID`. // // If no such task exists this should return `ErrMissingTask`. Get(id uuid.UUID) (models.Task, error) // GetAll returns every `models.Task` which is active // (not completed, not deleted). GetAll() ([]models.Task, error) // Goals returns the set of `models.Task`s which are parents of other tasks, // but are not depended on by another tasks. Goals() ([]models.Task, error) // Inbox returns the set of `models.Task`s which are // neither parents nor children of other tasks. Inbox() ([]models.Task, error) // Link inserts a connection between the task belonging to `parentID` // and the task belonging to `childID`. // // If linking this parent/child pair would create a cycle in the task graph // this function should return `ErrTaskCycle`. Link(parentID uuid.UUID, childID uuid.UUID) error // Todo recursively traverses the graph of tasks // and returns all leaf tasks in which children // of the task belonging to `id`. // // If the provided ID is invalid (aka, empty and would produce ""), // this should return `ErrInvalidID`. // // If no such task exists, or that task is already deleted, // this should return `ErrMissingTask`. Todo(id uuid.UUID) ([]models.Task, error) // Unlinks removes a link between the task belonging to `parentID` // and the task belonging to `childID`. Unlink(parentID uuid.UUID, childID uuid.UUID) error // Upsert inserts or replaces the provided task in the database. Upsert(task models.Task) error }
type SQLiteDatabase ¶
type SQLiteDatabase struct {
// contains filtered or unexported fields
}
func OpenSQLite ¶
func OpenSQLite(path string) (*SQLiteDatabase, error)
func (*SQLiteDatabase) Get ¶
Get retrieves a Task from the database with the provided ID. If the UUID is invalid, or there is no
func (*SQLiteDatabase) GetAll ¶
func (db *SQLiteDatabase) GetAll() ([]models.Task, error)
GetAll returns the total set of Tasks in the database. This is useful when one wants to perform a search over all possible tasks.
func (*SQLiteDatabase) Link ¶
Link links together two tasks, such that the task belonging to parentID is marked as depending on the task belonging to childID.
func (*SQLiteDatabase) Migrate ¶
func (db *SQLiteDatabase) Migrate() error
func (*SQLiteDatabase) Todo ¶
Todo returns all of all of the leaf nodes reachable by the provided id. This corresponds to tasks related to the provided task which are actionable.
Click to show internal directories.
Click to hide internal directories.