Documentation ¶
Index ¶
- func WithUnitOfWork(ctx context.Context, uow UnitOfWork) context.Context
- type Batch
- func (b *Batch) Add(collection string, v interface{}, opts ...BatchOption)
- func (b *Batch) All(spec Spec, v interface{}, opts ...BatchOption)
- func (b *Batch) Do(spec Spec, opts ...BatchOption)
- func (b *Batch) Edit(collection string, spec Spec, v interface{}, opts ...BatchOption)
- func (b *Batch) One(spec Spec, v interface{}, opts ...BatchOption)
- type BatchItem
- type BatchOption
- type DB
- type Repository
- type Spec
- type TxConfig
- type TxOption
- type UnitOfWork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithUnitOfWork ¶
func WithUnitOfWork(ctx context.Context, uow UnitOfWork) context.Context
Types ¶
type Batch ¶
type Batch []*BatchItem
Batch a list of batch query items
func (*Batch) Add ¶ added in v1.2.0
func (b *Batch) Add(collection string, v interface{}, opts ...BatchOption)
Add an item
func (*Batch) All ¶
func (b *Batch) All(spec Spec, v interface{}, opts ...BatchOption)
All append a query expecting multiple results
func (*Batch) Do ¶
func (b *Batch) Do(spec Spec, opts ...BatchOption)
Do append a query expecting a single result
func (*Batch) Edit ¶ added in v1.2.0
func (b *Batch) Edit(collection string, spec Spec, v interface{}, opts ...BatchOption)
Edit an item
func (*Batch) One ¶
func (b *Batch) One(spec Spec, v interface{}, opts ...BatchOption)
One append a query expecting a single result
type BatchOption ¶
type BatchOption func(item *BatchItem)
BatchOption for custom query configuration
func Optional ¶ added in v1.1.3
func Optional(flag bool) BatchOption
Optional marks the item as optional ignoring client errors
type DB ¶
type DB interface { Repository() Repository Begin(ctx context.Context, opts ...TxOption) (UnitOfWork, error) }
DB provides instances of transactions and repositories.
type Repository ¶
type Repository interface { One(ctx context.Context, spec Spec, v interface{}) error All(ctx context.Context, spec Spec, v interface{}) error Add(ctx context.Context, collection string, v interface{}) error Edit(ctx context.Context, collection string, spec Spec, v interface{}) error Remove(ctx context.Context, collection string, spec Spec) error Batch(ctx context.Context, batch Batch) error }
Repository abstraction for a collection of objects.
type Spec ¶
Spec for querying objects
type UnitOfWork ¶
type UnitOfWork interface { Tx() interface{} Commit(ctx context.Context) error Rollback(ctx context.Context) }
UnitOfWork to do
func UnitOfWorkValue ¶
func UnitOfWorkValue(ctx context.Context) (UnitOfWork, bool)
Click to show internal directories.
Click to hide internal directories.