obj

package
v0.0.0-...-e16c5d6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort[S any](
	specs []S,
	lessers ...Lesser[S],
)

Types

type Accessor

type Accessor[S any, T any] interface {
	Get(s S) T
	Name() string
	Set(s S, v T)
}

type DeleteBuilder

type DeleteBuilder[S any] interface {
	Where(filters ...Matcher[S]) DeleteBuilder[S]
	Run() (deleted []S, err error)
}

type InsertBuilder

type InsertBuilder[S any] interface {
	Set(mutators ...Mutator[S]) InsertBuilder[S]
	Run() (inserted S, err error)
}

type Lesser

type Lesser[S any] interface {
	Less(i, j S) int
}

func OrderBy

func OrderBy[S any, T constraints.Ordered](
	accessor Accessor[S, T],
) Lesser[S]

func OrderByDesc

func OrderByDesc[S any, T constraints.Ordered](
	accessor Accessor[S, T],
) Lesser[S]

type Matcher

type Matcher[S any] interface {
	Match(s S) bool
}

func And

func And[S any](matchers ...Matcher[S]) Matcher[S]

func Equals

func Equals[S any, T comparable](
	accessor Accessor[S, T],
	value T,
) Matcher[S]

func Noop

func Noop[S any]() Matcher[S]

func Or

func Or[S any](matchers ...Matcher[S]) Matcher[S]

type Mutator

type Mutator[S any] interface {
	Mutate(s S)
}

func NewMutator

func NewMutator[S any, V comparable](
	accessor Accessor[S, V],
	value V,
) Mutator[S]

type SelectBuilder

type SelectBuilder[S any] interface {
	Where(filters ...Matcher[S]) SelectBuilder[S]
	OrderBy(orderBys ...Lesser[S]) SelectBuilder[S]
	Run() (results []S, err error)
}

type SpecFactory

type SpecFactory[S any] interface {
	New() S
}

type Storage

type Storage[S any] interface {
	Delete(filters Matcher[S]) (deleted []S, err error)
	Insert(mutators []Mutator[S]) (inserted S, err error)
	Select(
		filters Matcher[S],
		orderBys []Lesser[S],
	) (results []S, err error)
	NewDeleteBuilder() DeleteBuilder[S]
	NewInsertBuilder() InsertBuilder[S]
	NewSelectBuilder() SelectBuilder[S]
	Update(
		filters Matcher[S],
		mutators []Mutator[S],
		orderBys []Lesser[S],
	) (updated []S, err error)
}

type UpdateBuilder

type UpdateBuilder[S any] interface {
	OrderBy(orderBys ...Lesser[S]) UpdateBuilder[S]
	Run() (updated []S, err error)
	Set(mutators ...Mutator[S]) UpdateBuilder[S]
	Where(filters ...Matcher[S]) UpdateBuilder[S]
}

Jump to

Keyboard shortcuts

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