database

package
v0.0.0-...-b7a6293 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDB

func GetDB() *gorm.DB

GetDB implements Singleton pattern to keep a single connection for all queries.

Types

type DBConnection

type DBConnection struct {
	Host, Port, User, Password, DBName string
}

DBConnection wraps information necessary to connect to a database.

func (DBConnection) Setup

func (dbConnection DBConnection) Setup()

Setup database connection based on parameters provided in the receiver.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository implements dependency injection for database connection.

func NewRepository

func NewRepository(db *gorm.DB) Repository

NewRepository constructs a new Repository so we don't need to expose Repository's internal fields.

func (*Repository) FindAll

func (r *Repository) FindAll(dest interface{}) bool

FindAll is an abstraction of gorm.Find. Searches all records of the desired interface.

func (*Repository) FindByField

func (r *Repository) FindByField(dest interface{}, query interface{}) bool

FindByField is an abstraction of gorm.Find. Finds the desired interface applying the provided query parameter.

func (*Repository) FindByID

func (r *Repository) FindByID(dest interface{}, id uint64) bool

FindByID is an abstraction of gorm.Find using primary key. Searches desired interface using provided primary key

func (*Repository) GetDB

func (r *Repository) GetDB() *gorm.DB

GetDB gives direct access to gorm.DB capabilities.

Jump to

Keyboard shortcuts

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