Documentation ¶
Index ¶
- Constants
- Variables
- type DBType
- type TaskDAO
- type TaskDAOMock
- func (s *TaskDAOMock) Delete(ID string) error
- func (s *TaskDAOMock) GetAll(start, end int) ([]model.Task, error)
- func (s *TaskDAOMock) GetByID(ID string) (*model.Task, error)
- func (s *TaskDAOMock) GetByStatus(status model.TaskStatus) ([]model.Task, error)
- func (s *TaskDAOMock) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
- func (s *TaskDAOMock) GetByTitle(title string) ([]model.Task, error)
- func (s *TaskDAOMock) Save(task *model.Task) error
- func (s *TaskDAOMock) Upsert(task *model.Task) (bool, error)
- type TaskDAOMongo
- func (s *TaskDAOMongo) Delete(ID string) error
- func (s *TaskDAOMongo) GetAll(start, end int) ([]model.Task, error)
- func (s *TaskDAOMongo) GetByID(ID string) (*model.Task, error)
- func (s *TaskDAOMongo) GetByStatus(status model.TaskStatus) ([]model.Task, error)
- func (s *TaskDAOMongo) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
- func (s *TaskDAOMongo) GetByTitle(title string) ([]model.Task, error)
- func (s *TaskDAOMongo) Save(task *model.Task) error
- func (s *TaskDAOMongo) Upsert(task *model.Task) (bool, error)
- type TaskDAOPostgres
- func (s *TaskDAOPostgres) Delete(ID string) error
- func (s *TaskDAOPostgres) GetAll(start, end int) ([]model.Task, error)
- func (s *TaskDAOPostgres) GetByID(ID string) (*model.Task, error)
- func (s *TaskDAOPostgres) GetByStatus(status model.TaskStatus) ([]model.Task, error)
- func (s *TaskDAOPostgres) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
- func (s *TaskDAOPostgres) GetByTitle(title string) ([]model.Task, error)
- func (s *TaskDAOPostgres) Save(task *model.Task) error
- func (s *TaskDAOPostgres) Upsert(task *model.Task) (bool, error)
Constants ¶
const (
// NoPaging used with skip, limit parameters
NoPaging = -1
)
Variables ¶
var ( // ErrInvalidUUID is used on invalid UUID number ErrInvalidUUID = errors.New("invalid input to UUID") // ErrNotFound is used when no result are found for the given parameters ErrNotFound = errors.New("no result found") )
var ( // ErrorDAONotFound is used for unknown DAO type ErrorDAONotFound = errors.New("unknown DAO type") )
var MockedTask = model.Task{ ID: uuid.NewV4().String(), Title: "Learn Go", Description: "Let's learn the Go programming language and how to use it in a real project to make great programs.", Status: model.StatusInProgress, Priority: model.PriorityHigh, CreationDate: time.Date(2017, 01, 01, 0, 0, 0, 0, time.UTC), DueDate: time.Date(2017, 01, 02, 0, 0, 0, 0, time.UTC), }
MockedTask is the task returned by this mocked interface
Functions ¶
This section is empty.
Types ¶
type DBType ¶
type DBType int
DBType lists the type of implementation the factory can return
const ( // DAOMongo is used for Mongo implementation of TaskDAO DAOMongo DBType = iota // DAOPostgres is used for PostgreSQL implementation of TaskDAO DAOPostgres // DAOMock is used for mocked implementation of TaskDAO DAOMock // DAOMockStr is the string representation of the DAOMock DBType DAOMockStr = "mock" )
func ParseDBType ¶
ParseDBType parses the string representation and returns the DBType or an error
type TaskDAO ¶
type TaskDAO interface { // GetByID returns a task by its ID GetByID(ID string) (*model.Task, error) // GetAll returns all tasks with paging capability GetAll(start, end int) ([]model.Task, error) // GetByTitle returns all tasks by title GetByTitle(title string) ([]model.Task, error) // GetByStatus returns all tasks by status GetByStatus(status model.TaskStatus) ([]model.Task, error) // GetByStatusAndPriority returns all tasks by status and priority GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error) // Save saves the task Save(task *model.Task) error // Upsert updates or creates a task, returns true if updated, false otherwise or on error Upsert(task *model.Task) (bool, error) // Delete deletes a tasks by its ID Delete(ID string) error }
TaskDAO is the DAO interface to work with tasks
func GetTaskDAO ¶
GetTaskDAO returns a TaskDAO according to type and params
func NewTaskDAOMock ¶
func NewTaskDAOMock() TaskDAO
NewTaskDAOMock creates a new TaskDAO with a mocked implementation
func NewTaskDAOMongo ¶
func NewTaskDAOMongo(session *mgo.Session) TaskDAO
NewTaskDAOMongo creates a new TaskDAO mongo implementation
func NewTaskDAOPostgres ¶
NewTaskDAOPostgres creates a new TaskDAO postgreSQL implementation
type TaskDAOMock ¶
type TaskDAOMock struct {
// contains filtered or unexported fields
}
TaskDAOMock is the mocked implementation of the TaskDAO
func (*TaskDAOMock) Delete ¶
func (s *TaskDAOMock) Delete(ID string) error
Delete deletes a tasks by its ID
func (*TaskDAOMock) GetAll ¶
func (s *TaskDAOMock) GetAll(start, end int) ([]model.Task, error)
GetAll returns all tasks with paging capability
func (*TaskDAOMock) GetByID ¶
func (s *TaskDAOMock) GetByID(ID string) (*model.Task, error)
GetByID returns a task by its ID
func (*TaskDAOMock) GetByStatus ¶
func (s *TaskDAOMock) GetByStatus(status model.TaskStatus) ([]model.Task, error)
GetByStatus returns all tasks by status
func (*TaskDAOMock) GetByStatusAndPriority ¶
func (s *TaskDAOMock) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
GetByStatusAndPriority returns all tasks by status and priority
func (*TaskDAOMock) GetByTitle ¶
func (s *TaskDAOMock) GetByTitle(title string) ([]model.Task, error)
GetByTitle returns all tasks by title
type TaskDAOMongo ¶
type TaskDAOMongo struct {
// contains filtered or unexported fields
}
TaskDAOMongo is the mongo implementation of the TaskDAO
func (*TaskDAOMongo) Delete ¶
func (s *TaskDAOMongo) Delete(ID string) error
Delete deletes a tasks by its ID
func (*TaskDAOMongo) GetAll ¶
func (s *TaskDAOMongo) GetAll(start, end int) ([]model.Task, error)
GetAll returns all tasks with paging capability
func (*TaskDAOMongo) GetByID ¶
func (s *TaskDAOMongo) GetByID(ID string) (*model.Task, error)
GetByID returns a task by its ID
func (*TaskDAOMongo) GetByStatus ¶
func (s *TaskDAOMongo) GetByStatus(status model.TaskStatus) ([]model.Task, error)
GetByStatus returns all tasks by status
func (*TaskDAOMongo) GetByStatusAndPriority ¶
func (s *TaskDAOMongo) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
GetByStatusAndPriority returns all tasks by status and priority
func (*TaskDAOMongo) GetByTitle ¶
func (s *TaskDAOMongo) GetByTitle(title string) ([]model.Task, error)
GetByTitle returns all tasks by title
type TaskDAOPostgres ¶
type TaskDAOPostgres struct {
// contains filtered or unexported fields
}
TaskDAOPostgres is the postgreSQL implementation of the TaskDAO
func (*TaskDAOPostgres) Delete ¶
func (s *TaskDAOPostgres) Delete(ID string) error
Delete deletes a tasks by its ID
func (*TaskDAOPostgres) GetAll ¶
func (s *TaskDAOPostgres) GetAll(start, end int) ([]model.Task, error)
GetAll returns all tasks with paging capability
func (*TaskDAOPostgres) GetByID ¶
func (s *TaskDAOPostgres) GetByID(ID string) (*model.Task, error)
GetByID returns a task by its ID
func (*TaskDAOPostgres) GetByStatus ¶
func (s *TaskDAOPostgres) GetByStatus(status model.TaskStatus) ([]model.Task, error)
GetByStatus returns all tasks by status
func (*TaskDAOPostgres) GetByStatusAndPriority ¶
func (s *TaskDAOPostgres) GetByStatusAndPriority(status model.TaskStatus, priority model.TaskPriority) ([]model.Task, error)
GetByStatusAndPriority returns all tasks by status and priority
func (*TaskDAOPostgres) GetByTitle ¶
func (s *TaskDAOPostgres) GetByTitle(title string) ([]model.Task, error)
GetByTitle returns all tasks by title