repository

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormRepository

type GormRepository struct {
}

GormRepository implements Repository

func (*GormRepository) Add

func (repository *GormRepository) Add(uow *UnitOfWork, entity interface{}) error

Add specified Entity

func (*GormRepository) Delete

func (repository *GormRepository) Delete(uow *UnitOfWork, entity interface{}) error

Delete specified Entity

func (*GormRepository) Get

func (repository *GormRepository) Get(uow *UnitOfWork, out interface{}, id uuid.UUID, preloadAssociations []string) error

Get a record for specified entity with specific id

func (*GormRepository) GetAll

func (repository *GormRepository) GetAll(uow *UnitOfWork, out interface{}, preloadAssociations []string) error

GetAll retrieves all the records for a specified entity and returns it

func (*GormRepository) GetAllForTenant added in v0.0.6

func (repository *GormRepository) GetAllForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, preloadAssociations []string) error

GetAllForTenant returns all objects of specifeid tenantID

func (*GormRepository) Update

func (repository *GormRepository) Update(uow *UnitOfWork, entity interface{}) error

Update specified Entity

type Repository

type Repository interface {
	Get(uow *UnitOfWork, out interface{}, id uuid.UUID, preloadAssociations []string) error
	GetAll(uow *UnitOfWork, out interface{}, preloadAssociations []string) error
	GetAllForTenant(uow *UnitOfWork, out interface{}, tenantID uuid.UUID, preloadAssociations []string) error
	Add(uow *UnitOfWork, out interface{}) error
	Update(uow *UnitOfWork, out interface{}) error
	Delete(uow *UnitOfWork, out interface{}) error
}

Repository represents generic interface for interacting with DB

func NewRepository

func NewRepository() Repository

NewRepository returns a new repository object

type UnitOfWork

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

UnitOfWork represents a connection

func NewUnitOfWork

func NewUnitOfWork(db *gorm.DB, readOnly bool) *UnitOfWork

NewUnitOfWork creates new UnitOfWork

func (*UnitOfWork) Commit

func (uow *UnitOfWork) Commit()

Commit the transaction

func (*UnitOfWork) Complete

func (uow *UnitOfWork) Complete()

Complete marks end of unit of work

Jump to

Keyboard shortcuts

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