Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteCreatedEntities ¶
DeleteCreatedEntities sets up GORM `onCreate` hook and return a function that can be deferred to remove all the entities created after the hook was set up You can use it as
func TestSomething(t *testing.T){ db, _ := gorm.Open(...) cleaner := DeleteCreatedEntities(db) defer cleaner()
}
func Initialize ¶
func Initialize(connSettings string) *database.Db
Initialize creates a singular connection to the backend database instance
func MigrateSchemas ¶
MigrateSchemas creates or updates a given set of models based on a schema if it does not exist or migrates the model schemas to the latest version
func SetupTests ¶
func SetupTests() *database.Db
init initializes a connection to the database initially and performs package level cleanup handler initialization
Types ¶
type Db ¶
Db witholds connection to a postgres database as well as a logging handler
func (*Db) PerformComplexTransaction ¶
PerformComplexTransaction takes as input an anonymous function witholding logic to perform within a transaction returning an abstract type. This function is then invoked within a transaction and depending on the occurrence of any specific errors, the transaction is either committed to the database or completely rolled back. This returns the result obtained from the invocation of the anonymous function as well as any error occuring throughout the transaction lifecycle.
func (*Db) PerformTransaction ¶
PerformTransaction takes as input an anonymous function witholding logic to perform within a transaction. This function is then invoked within a transaction. if unsuccessful or any error is raised throughout the transaction, then, the transaction is rolled back. Returned is any error occuring throughout the transaction lifecycle