Documentation
¶
Index ¶
- func ApplyConfiguration(db *gorm.DB, c *Configuration) *gorm.DB
- func ApplyOrderClauses(db *gorm.DB, ocs ...OrderClause) *gorm.DB
- func ApplyPreloadObjs(db *gorm.DB, preloadObjs ...string) *gorm.DB
- func ApplyScopes(db *gorm.DB, scopes ...Scope) *gorm.DB
- func ApplySelectFields(db *gorm.DB, selectFields ...string) *gorm.DB
- func ApplyWhereClauses(db *gorm.DB, wcs ...WhereClause) *gorm.DB
- func BeginTransaction(parentTransaction *gorm.DB, f func(*gorm.DB) error) error
- func SanitizePointer(p interface{}) (interface{}, error)
- func SliceToMap(src, dest interface{}) error
- func SliceToUUIDs(src, dest interface{}) error
- type BaseDAL
- func (d *BaseDAL) AppendAssociation(model interface{}, associationName string, associations interface{}, ...) error
- func (d *BaseDAL) ClearAssociation(model interface{}, associationName string, c *Configuration) error
- func (d *BaseDAL) CountAssociation(model interface{}, associationName string, c *Configuration) (int64, error)
- func (d *BaseDAL) Create(result interface{}, c *Configuration) error
- func (d *BaseDAL) DeleteAssociation(model interface{}, associationName string, associations interface{}, ...) error
- func (d *BaseDAL) First(result interface{}, c *Configuration) error
- func (d *BaseDAL) Get(result interface{}, id uint, c *Configuration) error
- func (d *BaseDAL) GetAssociation(result interface{}, model interface{}, associationName string, ...) error
- func (d *BaseDAL) Remove(result interface{}, c *Configuration) error
- func (d *BaseDAL) Update(result interface{}, c *Configuration) error
- func (d *BaseDAL) UpdateFields(result interface{}, fields map[string]interface{}, c *Configuration) error
- func (d *BaseDAL) Where(result interface{}, c *Configuration) error
- type Configuration
- type OrderClause
- type Scope
- type WhereClause
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyConfiguration ¶
func ApplyConfiguration(db *gorm.DB, c *Configuration) *gorm.DB
ApplyConfiguration applies the GORM configuration to database client.
func ApplyOrderClauses ¶
func ApplyOrderClauses(db *gorm.DB, ocs ...OrderClause) *gorm.DB
ApplyOrderClauses create new db pointer with order clauses applied.
func ApplyPreloadObjs ¶
ApplyPreloadObjs applies preload objects.
func ApplyScopes ¶
ApplyScopes apply scopes to gorm DB interactions.
func ApplySelectFields ¶
ApplySelectFields create new db pointer with select fields applied.
func ApplyWhereClauses ¶
func ApplyWhereClauses(db *gorm.DB, wcs ...WhereClause) *gorm.DB
ApplyWhereClauses create new db pointer with where clauses applied.
func BeginTransaction ¶
BeginTransaction starts a database transaction.
func SanitizePointer ¶
func SanitizePointer(p interface{}) (interface{}, error)
SanitizePointer checks whether or not the parameter passed in fits to GORM requirements for results (must be a pointer to a struct or slice).
See https://play.golang.org/p/kB6SPuOepwV for test cases.
func SliceToMap ¶
func SliceToMap(src, dest interface{}) error
SliceToMap converts slice of models to map of id to its respective model.
func SliceToUUIDs ¶
func SliceToUUIDs(src, dest interface{}) error
SliceToUUIDs converts slice of models to slice of uuids.
Types ¶
type BaseDAL ¶
BaseDAL encapsulates the basic operations of data access layers.
func GetInstance ¶
func GetInstance() *BaseDAL
GetInstance returns an instance of BaseDAL. If no instance is created yet then create one.
func (*BaseDAL) AppendAssociation ¶
func (d *BaseDAL) AppendAssociation( model interface{}, associationName string, associations interface{}, c *Configuration, ) error
AppendAssociation adds associations for a particular model to the database. @param model = *models @param associations = []models
func (*BaseDAL) ClearAssociation ¶
func (d *BaseDAL) ClearAssociation( model interface{}, associationName string, c *Configuration, ) error
ClearAssociation removes all reference between source and association. @param model = *models
func (*BaseDAL) CountAssociation ¶
func (d *BaseDAL) CountAssociation( model interface{}, associationName string, c *Configuration, ) (int64, error)
CountAssociation fetches the association count of a particular model from the database. @param model = *models
func (*BaseDAL) Create ¶
func (d *BaseDAL) Create(result interface{}, c *Configuration) error
Create inserts a record to the database with the model passed in. @param result = *models
func (*BaseDAL) DeleteAssociation ¶
func (d *BaseDAL) DeleteAssociation( model interface{}, associationName string, associations interface{}, c *Configuration, ) error
DeleteAssociation deletes associations for a particular model to the database. @param model = *models @param associations = []models
func (*BaseDAL) First ¶
func (d *BaseDAL) First(result interface{}, c *Configuration) error
First fetches the first record matching the criteria set in configuration.
func (*BaseDAL) Get ¶
func (d *BaseDAL) Get(result interface{}, id uint, c *Configuration) error
Get fetches the first record matching the UUID and the criteria set in configuration. @param result = *models
func (*BaseDAL) GetAssociation ¶
func (d *BaseDAL) GetAssociation( result interface{}, model interface{}, associationName string, c *Configuration, ) error
GetAssociation fetches the association of a particular model from the database. @param result = []models @param model = *models
func (*BaseDAL) Remove ¶
func (d *BaseDAL) Remove(result interface{}, c *Configuration) error
Remove deletes a record in the database with the model passed in. @param result = *models
func (*BaseDAL) Update ¶
func (d *BaseDAL) Update(result interface{}, c *Configuration) error
Update updates a record in the database with the model passed in. @param result = *models
func (*BaseDAL) UpdateFields ¶
func (d *BaseDAL) UpdateFields( result interface{}, fields map[string]interface{}, c *Configuration) error
UpdateFields updates a record in the database with specified fields to update. @param result = *models @param fields = map[string]interface{}
func (*BaseDAL) Where ¶
func (d *BaseDAL) Where(result interface{}, c *Configuration) error
Where fetches records matching the criteria set in configuration. @param result = *models
type Configuration ¶
type Configuration struct { Transaction *gorm.DB PreloadObjs []string SelectFields []string WhereClauses []WhereClause OrderClauses []OrderClause Scopes []Scope Unscoped bool }
Configuration GORM configuration to apply before final call.
type OrderClause ¶
type OrderClause struct {
Query interface{}
}
OrderClause used for DAL statements requiring order clauses.
type WhereClause ¶
type WhereClause struct { Query interface{} Args []interface{} }
WhereClause used for DAL statements requiring where clauses.