Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachFilter ¶
func ForEachFilter(stru interface{}, fn ForEachFunc) error
ForEachFilter reflects the struct an executes fn
func OpenConnection ¶
func OpenConnection(cfg ConnectionConfig) (connection *sql.DB, err error)
OpenConnection opens the connection pool
Types ¶
type ConnectionConfig ¶
ConnectionConfig is the parameters to open connection pool
type Filter ¶
type Filter interface {
ForEach(fn ForEachFunc) error
}
Filter represents the methods that must be implemented by any filter
type FilterPerson ¶
type FilterPerson struct {
ID *string `field:"id" form:"id" operator:"="`
Name *string `field:"name" form:"name" operator:"="`
City *string `field:"city" form:"city" operator:"="`
BirthDateEq *time.Time `field:"birth_date" form:"birth_date_eq" operator:"="`
BirthDateStart *time.Time `field:"birth_date" form:"birth_date_gte" operator:">="`
BirthDateEnd *time.Time `field:"birth_date" form:"birth_date_lte" operator:"<="`
WeightEq *float32 `field:"weight" form:"weight_eq" operator:"="`
WeightStart *float32 `field:"weight" form:"weight_gte" operator:">="`
WeightEnd *float32 `field:"weight" form:"weight_lte" operator:"<="`
HeightEq *float32 `field:"height" form:"height_eq" operator:"="`
HeightStart *float32 `field:"height" form:"height_gte" operator:">="`
HeightEnd *float32 `field:"height" form:"height_lte" operator:"<="`
}
FilterPerson filters the results of select statement
func (*FilterPerson) ForEach ¶
func (fp *FilterPerson) ForEach(fn ForEachFunc) error
ForEach iterates over the FilterPerson fields
type ForEachFunc ¶
ForEachFunc is the function that executes the query builder
type Person ¶
type Person struct {
ID *string `json:"id" db:"id"`
Name *string `json:"name" db:"name"`
City *string `json:"city" db:"city"`
BirthDate *time.Time `json:"birth_date" db:"birth_date"`
Weight *float32 `json:"weight" db:"weight"`
Height *float32 `json:"height" db:"height"`
}
Person represents a customer model
type PersonMethods ¶
type PersonMethods interface {
AddPerson(person Person) (lastID string, err error)
GetPerson(id string) (found bool, person Person, err error)
ListPersons(filter FilterPerson) (persons []Person, err error)
UpdatePerson(id string, person Person) (err error)
DeletePerson(id string) (err error)
}
PersonMethods represents the person's methods that must be implemented
type QueryBuilder ¶
type QueryBuilder interface {
PersonMethods
}
QueryBuilder represents the methods that must be implemented
Click to show internal directories.
Click to hide internal directories.