Documentation ¶
Overview ¶
Package dao provides access to the database. The main object is Source, from which a gorm.DB can be derived. The controllers are the methods used to access the database. Controllers are defined as methods on SOurce.
Index ¶
- type Source
- func (s *Source) AllProducts() models.Products
- func (s *Source) Close() error
- func (s *Source) CountProducts() int
- func (s *Source) CreateProduct(price uint, code string) uint
- func (s *Source) DeleteProduct(id uint)
- func (s *Source) DeleteProducts()
- func (s *Source) GetDB() *gorm.DB
- func (s *Source) GetProduct(id uint) *models.Product
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is used to generate a DAO object (singleton)
func NewMemorySource ¶
func NewMemorySource() *Source
NewMemorySource generate a memory database source
func NewPostgresSource ¶
func NewPostgresSource() *Source
NewPostgresSource generates a postgres source
func (*Source) AllProducts ¶
AllProducts dumps table content.
func (*Source) CountProducts ¶
CountProducts return the number of products in db.
func (*Source) CreateProduct ¶
CreateProduct register new product, return ID. Duplicates if already exists.
func (*Source) DeleteProduct ¶
DeleteProduct using primary key.
func (*Source) DeleteProducts ¶
func (s *Source) DeleteProducts()
DeleteProducts delete all products
Click to show internal directories.
Click to hide internal directories.