models

package
v0.0.0-...-eb224a2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 9 Imported by: 0

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

type ConnectionConfig struct {
	User, Password, Protocol, Address, DbName string
	Port                                      int
}

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

type ForEachFunc func(field, operator string, value interface{}) error

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

func (*Person) ToMap

func (p *Person) ToMap() map[string]interface{}

ToMap converts person struct to mpa

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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