crud

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Create is a constant representing create operations.
	Create = Op{"Create"}
	// Update is a constant representing update operations.
	Update = Op{"Update"}
	// Delete is a constant representing delete operations.
	Delete = Op{"Delete"}
)

Functions

This section is empty.

Types

type Actions

type Actions interface {
	Create(...Arg) (Arg, error)
	Delete(...Arg) (Arg, error)
	Update(...Arg) (Arg, error)
}

Actions is an interface for CRUD operations on any entity

type Arg

type Arg interface{}

Arg is an argument to a callback function.

type Kind

type Kind string

Kind represents Kind of an entity or object.

type Op

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

Op represents

func (*Op) String

func (op *Op) String() string

type Registry

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

Registry can hold Kinds and their respective CRUD operations.

func (*Registry) Create

func (r *Registry) Create(kind Kind, args ...Arg) (Arg, error)

Create calls the registered create action of kind with args and returns the result and error (if any).

func (*Registry) Delete

func (r *Registry) Delete(kind Kind, args ...Arg) (Arg, error)

Delete calls the registered delete action of kind with args and returns the result and error (if any).

func (*Registry) Do

func (r *Registry) Do(kind Kind, op Op, args ...Arg) (Arg, error)

Do calls an aciton based on op with args and returns the result and error.

func (*Registry) Get

func (r *Registry) Get(kind Kind) (Actions, error)

Get returns actions associated with kind. An error will be returned if kind was never registered.

func (*Registry) Register

func (r *Registry) Register(kind Kind, a Actions) error

Register a kind with actions. An error will be returned if kind was previously registered.

func (*Registry) Update

func (r *Registry) Update(kind Kind, args ...Arg) (Arg, error)

Update calls the registered update action of kind with args and returns the result and error (if any).

Jump to

Keyboard shortcuts

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