Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintSqlQuery ¶
func PrintSqlQuery(query string, args ...interface{})
printQuery prints a query if the user has enabled logging
func SetLogging ¶
SetLogging adjusts the configuration for logging. You can enable and disable the logging here. By default, logging is disabled.
Most calls to this function will be called like SetLogging(true, os.Stdout)
Types ¶
type BuildModel ¶
type BuildModel func() Model
BuildModel is a function that is responsible for returning a Model that is ready to have GetConfiguration() called
type BulkFetchConfig ¶
BulkFetchConfig is the configuration of a Model.BulkFetch()
func (*BulkFetchConfig) ConsumeSortQuery ¶
func (c *BulkFetchConfig) ConsumeSortQuery(sortQuery string)
ConsumeSortQuery consumes a `sort` query parameter and stuffs them into the OrderBys field
type Configuration ¶
Configuration is the metadata to be attached to a model
type Field ¶
type Field struct { Pointer interface{} Name string Insertable bool Updatable bool UniqueIdentifier bool SkipValidation bool GetReference func() (BuildModel, string) SetReference func(Model) error IsSet func(interface{}) bool }
Field is the definition of a single value in a model
type Model ¶
type Model interface { Insert() error Load() error Update() error Delete() error BulkFetch(BulkFetchConfig, BuildModel) ([]Model, error) GetConfiguration() *Configuration }
Model is the interface that defines the type that will be embedded on models
type OrderBy ¶
type OrderBy struct { Field string Type OrderByType }
OrderBy is the definition of a single order by clause
type OrderByType ¶
type OrderByType int
OrderByType is an enumeration of the SQL standard order by
const ( ORDER_BY_ASC OrderByType = iota ORDER_BY_DESC )
type PqModel ¶
type PqModel struct { Database *sql.DB `json:"-"` Config Configuration `json:"-"` }
PqModel is a github.com/lib/pq implementation of a Model
func (*PqModel) BulkFetch ¶
func (w *PqModel) BulkFetch(fetchConfig BulkFetchConfig, buildModel BuildModel) ([]Model, error)
BulkFetch gets an array of models
func (*PqModel) GetConfiguration ¶
func (w *PqModel) GetConfiguration() *Configuration
GetConfiguration returns the configuration for the model
type Predicate ¶
type Predicate struct { Field string PredicateType PredicateType Values []interface{} }
Predicate is the definition of a single where SQL predicate
type PredicateType ¶
type PredicateType int
const ( WHERE_IS_NOT_NULL PredicateType = iota // Default WHERE_IS_NULL WHERE_IN WHERE_NOT_IN WHERE_LIKE WHERE_EQUAL WHERE_NOT_EQUAL WHERE_GREATER_THAN WHERE_GREATER_THAN_OR_EQUAL_TO WHERE_LESS_THAN WHERE_LESS_THAN_OR_EQUAL_TO )