mttor

package
v0.0.0-...-3f675b9 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Applies specified mutation to target provided.
	Mutate(ctx context.Context, target, mutation interface{}) (err error)
}

Engine is component responsible for applying mutations passed into it. Typically, there is single global mutator handling all types.

func NewDefaultEngine

func NewDefaultEngine() (mutator Engine)

type Error

type Error struct {
	Descriptorion string
}

func (*Error) Error

func (err *Error) Error() string

type MongoEngine

type MongoEngine interface {
	RenderMongoMutation(ctx context.Context, targetType reflect.Type, mutation interface{}) (res interface{}, err error)
}

Mutator, which is able to apply mutations to mongo objects.

func NewMongoEngine

func NewMongoEngine() (mutator MongoEngine)

type MongoMutator

type MongoMutator interface {
	Mutator
	// Returns mongo mutation name, so appropriate bson.D can be passed.
	MongoMutationName() string
	RenderMongoDoc(ctx context.Context, data MongoMutatorData) (entry bson.E, err error)
}

Mutation, which is able to render itself as mongodb mutation.

type MongoMutatorData

type MongoMutatorData struct {
	MutatorData
	BSONFieldName string
	Skip          bool
}

type MutationArgs

type MutationArgs map[string][]string

func (MutationArgs) GetFirst

func (args MutationArgs) GetFirst(arg string) string

func (MutationArgs) IsSet

func (args MutationArgs) IsSet(arg string) bool

type Mutator

type Mutator interface {
	ApplyMutation(ctx context.Context, target reflect.Value, field stdesc.Field, data MutatorData) (err error)
}

Mutator is part of DefaultMutator, which applies mutation using data it's given.

type MutatorData

type MutatorData struct {
	Value interface{}

	Args         MutationArgs
	FieldName    string
	MutationName string
}

Jump to

Keyboard shortcuts

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