Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- func (db *DB) AllTasks() []Task
- func (db *DB) Close() error
- func (db *DB) Get(dest interface{}, query string, args ...interface{}) error
- func (db *DB) LastMod() (time.Time, error)
- func (db *DB) New(id, pid int, text string) *Task
- func (db *DB) ReplaceList(ts []Task) error
- func (db *DB) RootTasks() []Task
- func (db *DB) Select(dest interface{}, query string, args ...interface{}) error
- func (db *DB) TaskByID(id int) *Task
- func (db *DB) TasksToRemove() []Task
- func (db *DB) TasksToSync() []Task
- type Task
- func (t *Task) Add() error
- func (t *Task) Children() []Task
- func (t Task) MarshalJSON() ([]byte, error)
- func (t *Task) Remove() error
- func (t *Task) SetPID(pid int) *Task
- func (t *Task) SetText(text string) *Task
- func (t *Task) ToggleStatus() *Task
- func (t *Task) UnmarshalJSON(data []byte) error
- func (t *Task) UpMtime() *Task
- func (t *Task) Update() error
Constants ¶
const NoID = 0
NoID is a reserved ID value.
Variables ¶
var NoTime = time.Time{}
NoTime is a placeholder where a function is supposed to return a timestamp, but a meaningful value cannot be returned.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a database connection.
func InitDatabase ¶
InitDatabase opens a database connection and creates the tables if needed.
func (*DB) Close ¶
Close ends a database connection previously opened by `InitDatabase`. Should be called at the end of app lifespan.
func (*DB) ReplaceList ¶
ReplaceList atomically replaces all tasks in the database with the new list in a single transaction.
func (*DB) Select ¶
Select wraps sqlx.(*DB).Select, setting DB references in slice objects if those implement model.
func (*DB) TasksToRemove ¶
TasksToRemove returns every task that has ToRemove set.
func (*DB) TasksToSync ¶
TasksToSync returns every task that has ToSync set.
type Task ¶
type Task struct { ID int `db:"id"` PID int `db:"pid"` Text string `db:"ttext"` Completed bool `db:"completed"` Ctime time.Time `db:"ctime"` Mtime time.Time `db:"mtime"` Deadline time.Time `db:"deadline"` Reminder time.Time `db:"reminder"` ToSync bool `db:"tosync"` ToRemove bool `db:"toremove"` // contains filtered or unexported fields }
Task is a task model.
func (*Task) Add ¶
Add adds the task to the database. If task ID is unset, the first available database ID is picked (as per rowid in SQLite).
func (Task) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Task.
func (*Task) ToggleStatus ¶
ToggleStatus flips Task completed status. Use for chaining.
func (*Task) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Task.