mutation

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpAppend ...
	OpAppend = "append"
	// OpAssign ...
	OpAssign = "assign"
	// OpDelete ...
	OpDelete = "delete"
)
View Source
const (
	MutationType = "/object.mutation"
)

Variables

View Source
var (
	ErrParsingCursor     = errors.New("could not parse cursor")
	ErrNotImplemented    = errors.New("operation not implemented")
	ErrApplyingOperation = errors.New("could not apply operation")
)

Functions

This section is empty.

Types

type Mutation

type Mutation struct {
	Operations []*Operation `json:"ops:a<o>"`
	Parents    []string     `json:"@parents:a<s>"`
}

Mutation provides operations to be applied given that the parent mutations have already been applied

func New

func New(ops []*Operation, parents []string) *Mutation

New construct a mutation from an array of operations and parrent chains

func (*Mutation) FromObject

func (s *Mutation) FromObject(o *object.Object) error

FromObject populates the struct from a f12n object

func (Mutation) GetType

func (s Mutation) GetType() string

GetType returns the object's type

func (Mutation) Mutate

func (c Mutation) Mutate(o *object.Object) error

Mutate applies the mutation's operations on the given object

func (Mutation) ToObject

func (s Mutation) ToObject() *object.Object

ToObject returns a f12n object

type Operation

type Operation struct {
	Operation string      `json:"op:s"`
	Cursor    []string    `json:"cursor:a<s>"`
	Value     interface{} `json:"value"`
}

Operation ...

func (Operation) Apply

func (c Operation) Apply(o *object.Object) error

Apply ...

Jump to

Keyboard shortcuts

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