db

package
v0.0.0-...-02a6cbf Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbError

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

DbError is a custom error that shouldn't be sent out to clients

func (*DbError) Error

func (e *DbError) Error() string

Error returns custom DbError

type Instance

type Instance struct {
	Gorm *gorm.DB
	// contains filtered or unexported fields
}

Instance is a database client instance

func New

func New(c *env.Config) (*Instance, error)

New creates and initializes DB config

func (*Instance) AddEvent

func (i *Instance) AddEvent(e *dto.Event) error

AddEvent creates or updates event in the database based on the provided recipient_id, video_id and event_type

func (*Instance) AddRecipient

func (i *Instance) AddRecipient(r *model.Recipient) (int64, error)

AddRecipient creates new recipient in the database based on provided name, email and phone number

func (*Instance) CloseDb

func (i *Instance) CloseDb()

CloseDb closes database connection pool

func (*Instance) Get

func (i *Instance) Get(r *model.Recipient) ([]*model.Recipient, error)

Get selects recipient(s) from the database based on the provided id, name, email and phone number

func (*Instance) GetAll

func (i *Instance) GetAll() ([]*model.Recipient, error)

GetAll selects all recipients from the database

type Layer

type Layer interface {
	Get(*model.Recipient) ([]*model.Recipient, error)
	GetAll() ([]*model.Recipient, error)
	AddRecipient(*model.Recipient) (int64, error)
	AddEvent(*dto.Event) error
}

Layer is an interface that is used to create and read records from database

Jump to

Keyboard shortcuts

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