database

package
v0.0.0-...-988e5d4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2015 License: MPL-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Holds all what neccessary for odTimeTracker database - datatypes `Activity` and `Project` and functions for manipulating data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitStorage

func InitStorage(path string) (db *sql.DB, err error)

Initialize storage.

func RemoveActivity

func RemoveActivity(db *sql.DB, id ...int64) (int, error)

Remove activity(-ies) with given Id(s) form the database.

func RemoveProject

func RemoveProject(db *sql.DB, id ...int64) (int, error)

Remove project(s) with given Id(s) form the database.

func UpdateActivity

func UpdateActivity(db *sql.DB, a Activity) (cnt int64, err error)

Update activity in the database Return 1 if update was successfull otherwise 0.

func UpdateProject

func UpdateProject(db *sql.DB, p Project) (cnt int64, err error)

Update project in the database. Return 1 if update was successfull otherwise 0.

Types

type Activity

type Activity struct {
	ActivityId  int64
	ProjectId   int64
	Name        string
	Description string
	Tags        string
	Started     string
	Stopped     string
	// contains filtered or unexported fields
}

Activity definition

func InsertActivity

func InsertActivity(db *sql.DB, pid int64, name string, desc string, tags string) (a Activity, err error)

Insert new activity.

func SelectActivities

func SelectActivities(db *sql.DB, limit int) (activities []Activity, err error)

Return activities.

func SelectActivityById

func SelectActivityById(db *sql.DB, id ...int64) (a []Activity, err error)

Return activity(-ies) by given ID(s).

func SelectActivityRunning

func SelectActivityRunning(db *sql.DB) (a Activity, err error)

Return currently running activity.

func (*Activity) Duration

func (a *Activity) Duration() time.Duration

Returns duration of the activity.

func (*Activity) GetProject

func (a *Activity) GetProject() Project

Get project associated with the activity.

func (*Activity) Parse

func (a *Activity) Parse(db *sql.DB, activityString string) error

Initialize activity from the given string.

func (*Activity) SetProject

func (a *Activity) SetProject(p Project)

Set project associated with the activity.

func (*Activity) StartedTime

func (a *Activity) StartedTime() (time.Time, error)

Returns `Started` string as regular instance of `time.Time`.

func (*Activity) StoppedTime

func (a *Activity) StoppedTime() (time.Time, error)

Returns `Stopped` string as regular instance of `time.Time`.

type Project

type Project struct {
	ProjectId   int64  // Numeric identifier of the project.
	Name        string // Name of the project.
	Description string // Description of the project.
	Created     string // Datetime of creation of the project (formatted by RFC3339).
}

Project definition

func InsertProject

func InsertProject(db *sql.DB, name string, desc string) (p Project, err error)

Insert new project.

func SelectProjectById

func SelectProjectById(db *sql.DB, id ...int64) (p []Project, err error)

Return project(s) by given ID(s).

func SelectProjectByName

func SelectProjectByName(db *sql.DB, name ...string) (projects []Project, err error)

Return single project by given name(s).

func SelectProjectWithTerm

func SelectProjectWithTerm(db *sql.DB, term string) (projects []Project, err error)

Return project(s) which names contains given term.

func SelectProjects

func SelectProjects(db *sql.DB, limit int) (p []Project, err error)

Return projects.

func (*Project) CreatedTime

func (p *Project) CreatedTime() (time.Time, error)

Returns `Created` string as regular instance of `time.Time`.

Jump to

Keyboard shortcuts

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