Documentation ¶
Index ¶
- Constants
- Variables
- type DBType
- type SpiritDAO
- type SpiritDAOMock
- func (s *SpiritDAOMock) DeleteSpirit(ID string) error
- func (s *SpiritDAOMock) GetAllSpirits(start, end int) ([]model.Spirit, error)
- func (s *SpiritDAOMock) GetSpiritByID(ID string) (*model.Spirit, error)
- func (s *SpiritDAOMock) GetSpiritsByName(name string) ([]model.Spirit, error)
- func (s *SpiritDAOMock) GetSpiritsByType(spiritType string) ([]model.Spirit, error)
- func (s *SpiritDAOMock) GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error)
- func (s *SpiritDAOMock) SaveSpirit(spirit *model.Spirit) error
- func (s *SpiritDAOMock) UpsertSpirit(ID string, spirit *model.Spirit) (bool, error)
- type SpiritDAOMongo
- func (s *SpiritDAOMongo) DeleteSpirit(ID string) error
- func (s *SpiritDAOMongo) GetAllSpirits(start, end int) ([]model.Spirit, error)
- func (s *SpiritDAOMongo) GetSpiritByID(ID string) (*model.Spirit, error)
- func (s *SpiritDAOMongo) GetSpiritsByName(name string) ([]model.Spirit, error)
- func (s *SpiritDAOMongo) GetSpiritsByType(spiritType string) ([]model.Spirit, error)
- func (s *SpiritDAOMongo) GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error)
- func (s *SpiritDAOMongo) SaveSpirit(spirit *model.Spirit) error
- func (s *SpiritDAOMongo) UpsertSpirit(ID string, spirit *model.Spirit) (bool, error)
Constants ¶
const (
// NoPaging used with skip, limit parameters
NoPaging = -1
)
Variables ¶
var ( // ErrorDAONotFound is used for unknown DAO type ErrorDAONotFound = errors.New("Unknown DAO type") )
var MockedSpirit = model.Spirit{ Name: "Caroni", Distiller: "Caroni", Bottler: "Velier", Country: "Trinidad", Composition: "Molasse", SpiritType: model.TypeRhum, Age: 15, BottlingDate: time.Date(2015, 01, 01, 0, 0, 0, 0, time.UTC), Score: 8.5, Comment: "heavy tire taste", }
MockedSpirit is the spirit returned by this mocked interface
Functions ¶
This section is empty.
Types ¶
type SpiritDAO ¶
type SpiritDAO interface { // GetSpiritByID returns a spirit by its ID GetSpiritByID(ID string) (*model.Spirit, error) // GetAllSpirits returns all spirits with paging capability GetAllSpirits(start, end int) ([]model.Spirit, error) // GetSpiritsByName returns all spirits by name GetSpiritsByName(name string) ([]model.Spirit, error) // GetSpiritsByType returns all spirits by type GetSpiritsByType(spiritType string) ([]model.Spirit, error) // GetSpiritsByTypeAndScore returns all spirits by type and score greater than parameter GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error) // SaveSpirit saves the spirit SaveSpirit(spirit *model.Spirit) error // UpsertSpirit updates or creates a spirit UpsertSpirit(ID string, spirit *model.Spirit) (bool, error) // DeleteSpirit deletes a spirits by its ID DeleteSpirit(ID string) error }
SpiritDAO is the DAO interface to work with spirits
func GetSpiritDAO ¶
GetSpiritDAO returns a SpiritDAO according to type and params
func NewSpiritDAOMock ¶
func NewSpiritDAOMock() SpiritDAO
NewSpiritDAOMock creates a new SpiritDAO with a mocked implementation
func NewSpiritDAOMongo ¶
func NewSpiritDAOMongo(session *mgo.Session) SpiritDAO
NewSpiritDAOMongo creates a new SpiritDAO mongo implementation
type SpiritDAOMock ¶
type SpiritDAOMock struct { }
SpiritDAOMock is the mocked implementation of the SpiritDAO
func (*SpiritDAOMock) DeleteSpirit ¶
func (s *SpiritDAOMock) DeleteSpirit(ID string) error
DeleteSpirit deletes a spirits by its ID
func (*SpiritDAOMock) GetAllSpirits ¶
func (s *SpiritDAOMock) GetAllSpirits(start, end int) ([]model.Spirit, error)
GetAllSpirits returns all spirits with paging capability
func (*SpiritDAOMock) GetSpiritByID ¶
func (s *SpiritDAOMock) GetSpiritByID(ID string) (*model.Spirit, error)
GetSpiritByID returns a spirit by its ID
func (*SpiritDAOMock) GetSpiritsByName ¶
func (s *SpiritDAOMock) GetSpiritsByName(name string) ([]model.Spirit, error)
GetSpiritsByName returns all spirits by name
func (*SpiritDAOMock) GetSpiritsByType ¶
func (s *SpiritDAOMock) GetSpiritsByType(spiritType string) ([]model.Spirit, error)
GetSpiritsByType returns all spirits by type
func (*SpiritDAOMock) GetSpiritsByTypeAndScore ¶
func (s *SpiritDAOMock) GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error)
GetSpiritsByTypeAndScore returns all spirits by type and score greater than parameter
func (*SpiritDAOMock) SaveSpirit ¶
func (s *SpiritDAOMock) SaveSpirit(spirit *model.Spirit) error
SaveSpirit saves the spirit
func (*SpiritDAOMock) UpsertSpirit ¶
UpsertSpirit updates or creates a spirit
type SpiritDAOMongo ¶
type SpiritDAOMongo struct {
// contains filtered or unexported fields
}
SpiritDAOMongo is the mongo implementation of the SpiritDAO
func (*SpiritDAOMongo) DeleteSpirit ¶
func (s *SpiritDAOMongo) DeleteSpirit(ID string) error
DeleteSpirit deletes a spirits by its ID
func (*SpiritDAOMongo) GetAllSpirits ¶
func (s *SpiritDAOMongo) GetAllSpirits(start, end int) ([]model.Spirit, error)
GetAllSpirits returns all spirits with paging capability
func (*SpiritDAOMongo) GetSpiritByID ¶
func (s *SpiritDAOMongo) GetSpiritByID(ID string) (*model.Spirit, error)
GetSpiritByID returns a spirit by its ID
func (*SpiritDAOMongo) GetSpiritsByName ¶
func (s *SpiritDAOMongo) GetSpiritsByName(name string) ([]model.Spirit, error)
GetSpiritsByName returns all spirits by name
func (*SpiritDAOMongo) GetSpiritsByType ¶
func (s *SpiritDAOMongo) GetSpiritsByType(spiritType string) ([]model.Spirit, error)
GetSpiritsByType returns all spirits by type
func (*SpiritDAOMongo) GetSpiritsByTypeAndScore ¶
func (s *SpiritDAOMongo) GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error)
GetSpiritsByTypeAndScore returns all spirits by type and score greater than parameter
func (*SpiritDAOMongo) SaveSpirit ¶
func (s *SpiritDAOMongo) SaveSpirit(spirit *model.Spirit) error
SaveSpirit saves the spirit
func (*SpiritDAOMongo) UpsertSpirit ¶
UpsertSpirit updates or creates a spirit