model

package
v0.0.0-...-8e70ca2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CTaskUserID = 1 << iota

	CTaskID
	CTaskSubject
	CTaskDue
	CTaskPriority
	CTaskReminder
	CTaskNext
	CTaskNote
	CTaskParentTaskID

	CTaskTags

	CTaskSubTaskIDs
)

Column flag

View Source
const (
	DateLayout = "2006-01-02"
	TimeLayout = "15:04"
)

Variables

View Source
var (
	ShortColumnNames = map[string]string{
		"UserID":       "user_id",
		"ID":           "id",
		"Subject":      "subject",
		"Due":          "due",
		"Priority":     "priority",
		"Reminder":     "reminder",
		"Next":         "next",
		"Note":         "note",
		"ParentTaskID": "parent_task_id",
	}

	FullColumnNames = map[string]string{
		"UserID":       "task.user_id",
		"ID":           "task.id",
		"Subject":      "task.subject",
		"Due":          "task.due",
		"Priority":     "task.priority",
		"Reminder":     "task.reminder",
		"Next":         "task.next",
		"Note":         "task.note",
		"ParentTaskID": "task.parent_task_id",
	}
)

Column name string

View Source
var DBConn *pg.DB

Functions

func ChangePassword

func ChangePassword(userID string, password string) error

func ChangeUserID

func ChangeUserID(oldUserID, newUserID string) error

func CreateTask

func CreateTask(task Task) error

func CreateUser

func CreateUser(userID string, password string) error

func DeleteTask

func DeleteTask(task Task) error

func DeleteUser

func DeleteUser(userID string) error

func DoneTask

func DoneTask(task Task) error

func GetTagsByTaskID

func GetTagsByTaskID(taskID int64) ([]string, error)

func GetTagsByUserID

func GetTagsByUserID(userID string) ([]string, error)

func UpdateTask

func UpdateTask(task Task, columns int) error

Types

type Task

type Task struct {
	TableName struct{} `sql:"task" json:"-"`

	Tags []string `pg:",array"`

	SubTaskIDs []int64 `sql:"sub_task_ids" pg:",array" json:",string"`
	// contains filtered or unexported fields
}

func GetTask

func GetTask(userID string, taskID int64, columns int) (Task, error)

type Tasks

type Tasks []Task

Tasks is a slice of Task.

func GetTasksByFunc

func GetTasksByFunc(userID string, f func(q *orm.Query) *orm.Query, columns int) (Tasks, error)

func GetTasksByID

func GetTasksByID(userID string, ids []int64, columns int) (Tasks, error)

func GetTasksByTag

func GetTasksByTag(userID string, tagName string, columns int) (Tasks, error)

func GetTasksByUserID

func GetTasksByUserID(userID string, columns int) (Tasks, error)

func (Tasks) MarshalJSON

func (tasks Tasks) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

type Time

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

Time is a unix timestamp.

func NewTime

func NewTime(sec int64) Time

func (Time) Date

func (t Time) Date() string

Date returns string of the date.

func (Time) EqualZero

func (t Time) EqualZero() bool

EqualZero returns if Time == 0.

func (Time) Get

func (t Time) Get() int64

Get returns Time.sec.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Time) ParseDateTime

func (t *Time) ParseDateTime(dateStr string, timeStr string) error

ParseDateTime parses date & time string and sets Time.sec. If date is empty, Time.sec = 0. If date is not empty and time is empty, only date will be parsed.

func (*Time) Scan

func (t *Time) Scan(val interface{}) error

Scan implements sql.Scanner interface.

func (*Time) Set

func (t *Time) Set(sec int64)

Set sets Time.sec.

func (Time) String

func (t Time) String() string

String converts Time to string.

func (Time) Time

func (t Time) Time() string

Time returns string of the time.

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value implements sql.Valuer interface.

type User

type User struct {
	ID       string `sql:",pk"`
	Password string
}

func GetUser

func GetUser(userID string) (User, error)

Jump to

Keyboard shortcuts

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