Documentation
¶
Index ¶
- type GormDatabaseAccess
- func (gda *GormDatabaseAccess) Create(entity interface{}) error
- func (gda *GormDatabaseAccess) DB() *gorm.DB
- func (gda *GormDatabaseAccess) DeleteEntity(entityContainer interface{}) error
- func (gda *GormDatabaseAccess) GetEntities(entities interface{}, conditions ...interface{}) error
- func (gda *GormDatabaseAccess) GetFirstEntity(entityContainer interface{}, conditions ...interface{}) error
- func (gda *GormDatabaseAccess) GetLastEntity(entityContainer interface{}, conditions ...interface{}) error
- func (gda *GormDatabaseAccess) RegisterEntity(entityType interface{}) error
- func (gda *GormDatabaseAccess) Save(entity interface{}) error
- func (gda *GormDatabaseAccess) UpdateEntity(entityContainer interface{}, column string, value interface{}) error
- func (gda *GormDatabaseAccess) WorkOn(entityContainer interface{}) *gorm.DB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GormDatabaseAccess ¶
type GormDatabaseAccess struct {
// contains filtered or unexported fields
}
GormDatabaseAccess is a container struct that holds the gorm.DB instance to use for database interaction.
func New ¶
func New(db *gorm.DB) *GormDatabaseAccess
New creates a new GormDatabaseAccess instance for the database API
func (*GormDatabaseAccess) Create ¶
func (gda *GormDatabaseAccess) Create(entity interface{}) error
Create creates the passed entity in the entities
func (*GormDatabaseAccess) DB ¶
func (gda *GormDatabaseAccess) DB() *gorm.DB
DB returns the gorm.DB instance used by the entities api.
func (*GormDatabaseAccess) DeleteEntity ¶
func (gda *GormDatabaseAccess) DeleteEntity(entityContainer interface{}) error
DeleteEntity deletes the passed entity from the entities.
func (*GormDatabaseAccess) GetEntities ¶
func (gda *GormDatabaseAccess) GetEntities(entities interface{}, conditions ...interface{}) error
GetEntities fills the passed entities slice with the entities that have been found for the specified condition.
func (*GormDatabaseAccess) GetFirstEntity ¶
func (gda *GormDatabaseAccess) GetFirstEntity(entityContainer interface{}, conditions ...interface{}) error
GetFirstEntity fills the passed entity container with the first found entity matching the passed conditions.
Returns an error if no record could be found.
func (*GormDatabaseAccess) GetLastEntity ¶
func (gda *GormDatabaseAccess) GetLastEntity(entityContainer interface{}, conditions ...interface{}) error
GetLastEntity fills the passed entity container with the last found entity matching the passed conditions.
Returns false if no entries could be found.
func (*GormDatabaseAccess) RegisterEntity ¶
func (gda *GormDatabaseAccess) RegisterEntity(entityType interface{}) error
RegisterEntity registers a new entity (struct) and runs its automated migration to ensure the database schema is up-to-date.
func (*GormDatabaseAccess) Save ¶
func (gda *GormDatabaseAccess) Save(entity interface{}) error
Save upserts the passed entity in the entities
func (*GormDatabaseAccess) UpdateEntity ¶
func (gda *GormDatabaseAccess) UpdateEntity(entityContainer interface{}, column string, value interface{}) error
UpdateEntity can be used to update the passed entity in the entities
func (*GormDatabaseAccess) WorkOn ¶
func (gda *GormDatabaseAccess) WorkOn(entityContainer interface{}) *gorm.DB
WorkOn returns a gorm.DB pointer that allows to do a custom search or actions on entities.
The returned gorm.DB instance is created by using gorm.DB.Model() and is therefore already prepared to get started with applying filters. This function is the only interface point to get direct access to gorm.DB