database

package
v0.0.0-...-8ad1ab3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabaseError = errors.New("Database error")
View Source
var ErrNoAccess = errors.New("No access to entity")
View Source
var ErrNotFound = errors.New("Entity not found")

Functions

This section is empty.

Types

type AuthorizedTransactionAccessor

type AuthorizedTransactionAccessor interface {
	GetForBusiness(business *Business, transactionCode string) (*Transaction, error)
	GetForUser(user *User, transactionCode string) (*Transaction, error)
}

type AuthorizedTransactionAccessorImpl

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

func CreateAuthorizedTransactionAccessorImpl

func CreateAuthorizedTransactionAccessorImpl(database GormDB) *AuthorizedTransactionAccessorImpl

func (*AuthorizedTransactionAccessorImpl) GetForBusiness

func (accessor *AuthorizedTransactionAccessorImpl) GetForBusiness(business *Business, transactionCode string) (*Transaction, error)

func (*AuthorizedTransactionAccessorImpl) GetForUser

func (accessor *AuthorizedTransactionAccessorImpl) GetForUser(user *User, transactionCode string) (*Transaction, error)

type BusinessAuthorizedAccessor

type BusinessAuthorizedAccessor interface {
	Get(business *Business, cond BusinessOwnedEntity) (BusinessOwnedEntity, error)
	GetAll(business *Business, cond BusinessOwnedEntity) ([]BusinessOwnedEntity, error)
}

type BusinessAuthorizedAccessorImpl

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

func CreateBusinessAuthorizedAccessorImpl

func CreateBusinessAuthorizedAccessorImpl(database GormDB) *BusinessAuthorizedAccessorImpl

func (*BusinessAuthorizedAccessorImpl) Get

func (accessor *BusinessAuthorizedAccessorImpl) Get(business *Business, conds BusinessOwnedEntity) (BusinessOwnedEntity, error)

func (*BusinessAuthorizedAccessorImpl) GetAll

func (accessor *BusinessAuthorizedAccessorImpl) GetAll(business *Business, conds BusinessOwnedEntity) ([]BusinessOwnedEntity, error)

NOTE shouldnt be used for huge amounts of data

type BusinessOwnedEntity

type BusinessOwnedEntity interface {
	OwnedEntity
	GetBusinessId(db GormDB) (uint, error)
}

type OwnedEntity

type OwnedEntity interface {
}

type UserAuthorizedAccessor

type UserAuthorizedAccessor interface {
	Get(user *User, cond UserOwnedEntity) (UserOwnedEntity, error)
	GetAll(user *User, cond UserOwnedEntity, preloads []string) ([]UserOwnedEntity, error)
}

type UserAuthorizedAccessorImpl

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

func CreateUserAuthorizedAccessorImpl

func CreateUserAuthorizedAccessorImpl(database GormDB) *UserAuthorizedAccessorImpl

func (*UserAuthorizedAccessorImpl) Get

func (accessor *UserAuthorizedAccessorImpl) Get(user *User, conds UserOwnedEntity) (UserOwnedEntity, error)

func (*UserAuthorizedAccessorImpl) GetAll

func (accessor *UserAuthorizedAccessorImpl) GetAll(user *User, conds UserOwnedEntity, preloads []string) ([]UserOwnedEntity, error)

NOTE not optimized for huge amounts of data NOTE preloads will most likely get deprecated. Be careful with relation properties in objects returned by accessors. Loaded relation object does not mean that the object is owned and can be modified by business/user. This is a problem with both managers and accessors. Without preloads, there is no guarantee that relation properties will be loaded in the object. Perhaps forbidding use of relation properties in the whole codebase, except for code that directly interacts with the database would be a good idea.

type UserOwnedEntity

type UserOwnedEntity interface {
	OwnedEntity
	GetUserId(db GormDB) (uint, error)
}

Directories

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

Jump to

Keyboard shortcuts

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