mem

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package mem contains in-memory implementations of hohin interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB implements hohin.DB for an in-memory data structure.

func NewDB

func NewDB() *DB

NewDB creates a DB.

func (*DB) Simple

func (db *DB) Simple() hohin.SimpleDB

func (*DB) Transaction

func (db *DB) Transaction(ctx context.Context, f func(context.Context, hohin.DB) error) error

func (*DB) Tx

func (db *DB) Tx(ctx context.Context, _ hohin.IsolationLevel, f func(context.Context, hohin.DB) error) error

type Repo

type Repo[T any] struct {
	// contains filtered or unexported fields
}

Repo implements hohin.Repo for an in-memory data structure.

func NewRepo

func NewRepo[T any](collection string) *Repo[T]

NewRepo creates a Repo.

func (*Repo[T]) Add

func (r *Repo[T]) Add(ctx context.Context, d hohin.DB, entity T) error

func (*Repo[T]) AddMany

func (r *Repo[T]) AddMany(ctx context.Context, d hohin.DB, entities []T) error

func (*Repo[T]) Clear

func (r *Repo[T]) Clear(ctx context.Context, d hohin.DB) error

func (Repo[T]) Count

func (r Repo[T]) Count(ctx context.Context, d hohin.DB, f hohin.Filter) (uint64, error)

func (*Repo[T]) CountAll

func (r *Repo[T]) CountAll(ctx context.Context, d hohin.DB) (uint64, error)

func (*Repo[T]) Delete

func (r *Repo[T]) Delete(ctx context.Context, d hohin.DB, f hohin.Filter) error

func (*Repo[T]) Exists

func (r *Repo[T]) Exists(ctx context.Context, d hohin.DB, f hohin.Filter) (bool, error)

func (*Repo[T]) Get

func (r *Repo[T]) Get(ctx context.Context, d hohin.DB, f hohin.Filter) (T, error)

func (*Repo[T]) GetFirst

func (r *Repo[T]) GetFirst(ctx context.Context, d hohin.DB, q hohin.Query) (T, error)

func (*Repo[T]) GetForUpdate

func (r *Repo[T]) GetForUpdate(ctx context.Context, d hohin.DB, f hohin.Filter) (T, error)

func (*Repo[T]) GetMany

func (r *Repo[T]) GetMany(ctx context.Context, d hohin.DB, q hohin.Query) ([]T, error)

func (*Repo[T]) Simple

func (r *Repo[T]) Simple() hohin.SimpleRepo[T]

func (*Repo[T]) Update

func (r *Repo[T]) Update(ctx context.Context, d hohin.DB, f hohin.Filter, entity T) error

Jump to

Keyboard shortcuts

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