database

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoActiveConnection defines the error when an action wants to be performed
	// but no connection to the database is active
	ErrNoActiveConnection = errors.New("there is not active connection")

	// ErrRecordNotFound defines the error when there was an attempt to fetch/update/replace
	// a record but the record was not found
	ErrRecordNotFound = errors.New("record not found")

	// ErrRecordNotUpdated defines the error when there was an attempt to update/replace
	// a record but the action was not successful
	ErrRecordNotUpdated = errors.New("record not updated")

	// ErrRecordNotDeleted defines the error when there was an attempt to delete
	// a record but the action was not successful
	ErrRecordNotDeleted = errors.New("record not deleted")
)

Functions

This section is empty.

Types

type DatabaseClient

type DatabaseClient interface {
	// Disconnect performs any action to proper connect
	// and create a connection with the database
	Connect(context.Context, time.Duration) error
	// Disconnect performs any action to proper disconnect
	// and close any connection with the database
	Disconnect(context.Context) error
	// DeleteOne deletes a single record in database
	DeleteOne(
		context.Context,
		string,
		query.QueryBuilder,
	) error
	// Find returns multiple records from the database
	Find(
		context.Context,
		string,
		query.QueryBuilder,
		interface{},
	) error
	// FindOne fetches a single record in database
	FindOne(
		context.Context,
		string,
		query.QueryBuilder,
		interface{},
	) error
	// InsertOne stores a single record
	// in the specified table/collection
	// and returns the id of the stored record
	InsertOne(
		context.Context,
		string,
		interface{},
	) (string, error)
	// UpdateOne updates a single record in database
	UpdateOne(
		context.Context,
		string,
		query.QueryBuilder,
		interface{},
	) error
}

DatabaseClient defines a handler to manage actions against databases

type DatabaseConfiguration

type DatabaseConfiguration map[string]string

DatabaseConfiguration defines all the parameters needed to proper configure a connection to a database

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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