repository

package
v0.0.0-...-833fa1d Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package repository contains control entety repositories

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListOptionsInit

func ListOptionsInit[F, O QueryPreparer](opts ...ListOption[F, O]) *listOptions[F, O]

ListOptionsInit initialize list options

func PrepareListOptions

func PrepareListOptions[F, O QueryPreparer](db *gorm.DB, opts ...ListOption[F, O]) *gorm.DB

PrepareListOptions prepare query with options

Types

type ListOption

type ListOption[F, O QueryPreparer] func(*listOptions[F, O])

Option for list query

func WithFilter

func WithFilter[F, O QueryPreparer](filter F) ListOption[F, O]

WithFilter option for list query

func WithOrder

func WithOrder[F, O QueryPreparer](order O) ListOption[F, O]

WithOrder option for list query

func WithPagination

func WithPagination[F, O QueryPreparer](page *Pagination) ListOption[F, O]

WithPagination option for list query

type ListOptions

type ListOptions[F QueryPreparer, O QueryPreparer] []ListOption[F, O]

ListOptions for query preparation

func (ListOptions[F, O]) PrepareQuery

func (opts ListOptions[F, O]) PrepareQuery(query *gorm.DB) *gorm.DB

func (ListOptions[F, O]) WithFilter

func (opts ListOptions[F, O]) WithFilter(filter F) ListOptions[F, O]

func (ListOptions[F, O]) WithOrder

func (opts ListOptions[F, O]) WithOrder(order O) ListOptions[F, O]

func (ListOptions[F, O]) WithPagination

func (opts ListOptions[F, O]) WithPagination(page *Pagination) ListOptions[F, O]

type Pagination

type Pagination struct {
	Offset int
	Page   int
	Size   int
}

Pagination of the objects list

func (*Pagination) PrepareQuery

func (p *Pagination) PrepareQuery(q *gorm.DB) *gorm.DB

PrepareQuery prepare query with pagination

type QueryPreparer

type QueryPreparer interface {
	PrepareQuery(query *gorm.DB) *gorm.DB
}

QueryPreparer prepare query

type Repository

type Repository struct{}

Repository with basic functionality

func (*Repository) Logger

func (r *Repository) Logger(ctx context.Context) *zap.Logger

Logger returns logger object from context

func (*Repository) Master

func (r *Repository) Master(ctx context.Context) *gorm.DB

Master returns master database executor TODO: rename to Leader

func (*Repository) PermissionManager

func (r *Repository) PermissionManager(ctx context.Context) *permissions.Manager

PermissionManager returns permission-manager object from context

func (*Repository) Slave

func (r *Repository) Slave(ctx context.Context) *gorm.DB

Slave returns readonly database connection TODO: rename to ReadOnly

func (*Repository) Transaction

func (r *Repository) Transaction(ctx context.Context) (*gorm.DB, context.Context, bool, error)

Transaction returns new or exists transaction executor

func (*Repository) TransactionExec

func (r *Repository) TransactionExec(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error, dbs ...*gorm.DB) error

TransactionExec executes function in transaction

Directories

Path Synopsis
Package account present full API functionality of the specific object
Package account present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase account implementation
Package usecase account implementation
Package account present full API functionality of the specific object
Package account present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase account implementation
Package usecase account implementation
Package account present full API functionality of the specific object
Package account present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase account implementation
Package usecase account implementation
Package option present full API functionality of the specific object
Package option present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase account implementation
Package usecase account implementation
Package account present full API functionality of the specific object
Package account present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase account implementation
Package usecase account implementation
Package user present full API functionality of the specific object
Package user present full API functionality of the specific object
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
repository
Package repository implements methods of working with the repository objects
Package repository implements methods of working with the repository objects
usecase
Package usecase user managing
Package usecase user managing

Jump to

Keyboard shortcuts

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