model

package
v0.0.0-...-74d770d Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TODO_GROUP_INSERT_QUERY = `` /* 185-byte string literal not displayed */

	TODO_GROUP_UPDATE_QUERY = `` /* 163-byte string literal not displayed */

	TODO_GROUP_DELETE_QUERY = `
		DELETE FROM
			"todo_groups"
		WHERE
			"id" = :id
	`
	TODO_GROUP_SELECT_QUERY = `
		SELECT
			"id",
			"title",
			"created_at",
			"updated_at",
			"list_id"
		FROM
			"todo_groups"
	`
	TODO_GROUP_SELECT_ID_QUERY = TODO_GROUP_SELECT_QUERY + `
		WHERE
			id = ?
	`
	TODO_GROUP_SELECT_WITH_LIST_QUERY = TODO_GROUP_SELECT_QUERY + `
		WHERE
			list_id = ?
	`
	TODO_GROUP_SELECT_IDS_WITH_LIST_QUERY = `
		SELECT 
			"id" 
		FROM 
			"todo_groups"
		WHERE 
			"list_id" = ?
	`
)
View Source
var (
	TODO_ITEM_INSERT_QUERY = `` /* 269-byte string literal not displayed */

	TODO_ITEM_UPDATE_QUERY = `` /* 241-byte string literal not displayed */

	TODO_ITEM_DELETE_QUERY = `
		DELETE FROM
			"todo_items"
		WHERE
			"id" = :id
	`
	TODO_ITEM_SELECT_QUERY = `` /* 146-byte string literal not displayed */

	TODO_ITEM_SELECT_ID_QUERY = TODO_ITEM_SELECT_QUERY + `
		WHERE
			id = ?
	`
	TODO_ITEM_SELECT_WITH_GROUP_QUERY = TODO_ITEM_SELECT_QUERY + `
		WHERE
			group_id = ?
	`
	TODO_ITEM_SELECT_IDS_WITH_GROUP_QUERY = `
		SELECT 
			"id" 
		FROM 
			"todo_items"
		WHERE 
			"group_id" = ?
	`
)
View Source
var (
	TODO_LIST_INSERT_QUERY = `` /* 192-byte string literal not displayed */

	TODO_LIST_UPDATE_QUERY = `` /* 170-byte string literal not displayed */

	TODO_LIST_DELETE_QUERY = `
		DELETE FROM
			"todo_lists"
		WHERE
			"id" = :id
	`
	TODO_LIST_SELECT_QUERY = `
		SELECT
			"id",
			"title",
			"description",
			"created_at",
			"updated_at"
		FROM
			"todo_lists"
	`
	TODO_LIST_SELECT_ID_QUERY = TODO_LIST_SELECT_QUERY + `
		WHERE
			id = ?
	`
)
View Source
var (
	GroupNotFound = errors.New("List Not Found")
)
View Source
var (
	ItemNotFound = errors.New("Item Not Found")
)
View Source
var (
	ListNotFound = errors.New("List Not Found")
)

Functions

This section is empty.

Types

type TodoGroup

type TodoGroup struct {
	ID        dbtype.NullInt64 `json:"id,string"`
	Title     string           `json:"title"`
	CreatedAt *time.Time       `json:"createdAt" db:"created_at"`
	UpdatedAt *time.Time       `json:"updatedAt" db:"updated_at"`
	ListID    int64            `json:"list,string" db:"list_id"`
	List      *TodoList        `json:"-"`
	ItemIDs   []int64          `json:"items,string"`
	Items     []*TodoItem      `json:"-"`
}

type TodoGroupRepository

type TodoGroupRepository struct {
	DB *sqlx.DB
}

func NewTodoGroupRepository

func NewTodoGroupRepository(db *sqlx.DB) *TodoGroupRepository

func (*TodoGroupRepository) AddGroupsToList

func (repo *TodoGroupRepository) AddGroupsToList(l *TodoList) error

func (*TodoGroupRepository) Delete

func (repo *TodoGroupRepository) Delete(id int64) error

func (*TodoGroupRepository) Find

func (repo *TodoGroupRepository) Find(id int64) (*TodoGroup, error)

func (*TodoGroupRepository) GetAll

func (repo *TodoGroupRepository) GetAll() ([]*TodoGroup, error)

func (*TodoGroupRepository) GetAllForList

func (repo *TodoGroupRepository) GetAllForList(listID int64) ([]*TodoGroup, error)

func (*TodoGroupRepository) Insert

func (repo *TodoGroupRepository) Insert(group *TodoGroup) error

func (*TodoGroupRepository) SetItemIDs

func (repo *TodoGroupRepository) SetItemIDs(g *TodoGroup) error

func (*TodoGroupRepository) Update

func (repo *TodoGroupRepository) Update(group *TodoGroup) error

type TodoItem

type TodoItem struct {
	ID          dbtype.NullInt64 `json:"id,string"`
	Title       string           `json:"title"`
	Description string           `json:"description"`
	Done        bool             `json:"done"`
	DoneAt      *time.Time       `json:"doneAt" db:"done_at"`
	CreatedAt   *time.Time       `json:"createdAt" db:"created_at"`
	UpdatedAt   *time.Time       `json:"updatedAt" db:"updated_at"`
	GroupID     int64            `json:"group,string" db:"group_id"`
	Group       *TodoGroup       `json:"-"`
}

type TodoItemRepository

type TodoItemRepository struct {
	DB *sqlx.DB
}

func NewTodoItemRepository

func NewTodoItemRepository(db *sqlx.DB) *TodoItemRepository

func (*TodoItemRepository) AddItemsToGroup

func (repo *TodoItemRepository) AddItemsToGroup(g *TodoGroup) error

func (*TodoItemRepository) Delete

func (repo *TodoItemRepository) Delete(id int64) error

func (*TodoItemRepository) Find

func (repo *TodoItemRepository) Find(id int64) (*TodoItem, error)

func (*TodoItemRepository) GetAll

func (repo *TodoItemRepository) GetAll() ([]*TodoItem, error)

func (*TodoItemRepository) GetAllForGroup

func (repo *TodoItemRepository) GetAllForGroup(groupID int64) ([]*TodoItem, error)

func (*TodoItemRepository) Insert

func (repo *TodoItemRepository) Insert(item *TodoItem) error

func (*TodoItemRepository) Update

func (repo *TodoItemRepository) Update(item *TodoItem) error

type TodoList

type TodoList struct {
	ID          dbtype.NullInt64 `json:"id,string"`
	Title       string           `json:"title"`
	Description string           `json:"description"`
	CreatedAt   *time.Time       `json:"createdAt" db:"created_at"`
	UpdatedAt   *time.Time       `json:"updatedAt" db:"updated_at"`
	GroupIDs    []int64          `json:"groups,string"`
	Groups      []*TodoGroup     `json:"-"`
}

type TodoListRepository

type TodoListRepository struct {
	DB *sqlx.DB
}

func NewTodoListRepository

func NewTodoListRepository(db *sqlx.DB) *TodoListRepository

func (*TodoListRepository) Delete

func (repo *TodoListRepository) Delete(id int64) error

func (*TodoListRepository) Find

func (repo *TodoListRepository) Find(id int64) (*TodoList, error)

func (*TodoListRepository) GetAll

func (repo *TodoListRepository) GetAll() ([]*TodoList, error)

func (*TodoListRepository) Insert

func (repo *TodoListRepository) Insert(list *TodoList) error

func (*TodoListRepository) SetGroupIDs

func (repo *TodoListRepository) SetGroupIDs(l *TodoList) error

func (*TodoListRepository) Update

func (repo *TodoListRepository) Update(list *TodoList) error

Jump to

Keyboard shortcuts

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