services

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseAccess

type DatabaseAccess interface {
	// RegisterEntity registers a new entity (struct) and ensures the
	// entities schema knows about the entity.
	RegisterEntity(entityType interface{}) error

	// Create creates the passed entity in the entities
	Create(entity interface{}) error
	// Save upserts the passed entity in the entities
	Save(entity interface{}) error
	// UpdateEntity can be used to update the passed entity in the entities
	UpdateEntity(entityContainer interface{}, column string, value interface{}) error
	// DeleteEntity deletes the passed entity from the entities.
	DeleteEntity(entityContainer 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.
	GetFirstEntity(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.
	GetLastEntity(entityContainer interface{}, conditions ...interface{}) error
	// GetEntities fills the passed entities slice with the entities
	// that have been found for the specified condition.
	GetEntities(entities interface{}, conditions ...interface{}) error

	// 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
	WorkOn(entityContainer interface{}) *gorm.DB

	// DB returns the reference to the used gorm.DB instance.
	DB() *gorm.DB
}

DatabaseAccess is an interface thar provides functions for low level entities operations that bypass the entity manager API.

This is part of the low-level API. Prefer using the entity API instead of this one!

Unlike other parts of the API, this is a direct wrapper around gorm.DB and forces the application to redirect all calls through the API. Also, all entities of the application are based on GORMs definition. This means it is not possible to just swap the used ORM implementation, like it would be for other parts of the API.

This interface exists to provide a unified and easy way to access the GORM functions and gorm.DB itself. A nice side effect is, that the wrapped functions have improved error handling by automatically passing down errors.

type Logger

type Logger interface {
	Debug(format string, v ...interface{})
	Info(format string, v ...interface{})
	Warn(format string, v ...interface{})
	Err(err error, format string, v ...interface{})
}

Logger provides useful methods that ease logging.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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