Documentation
¶
Index ¶
- Variables
- func ApplyMutation(oldVal interface{}, mutation map[string]interface{}) (interface{}, error)
- func ApplyMutationObject(oldObj, mutations map[string]interface{}) (map[string]interface{}, error)
- func BuildMutation(oldObj, newObj map[string]interface{}) map[string]interface{}
- type IndexMutation
- type Mutation
- type MutationImplementation
- type MutationType
- type PullMutation
- type PushMutation
- type SetMutation
- type TruncateMutation
- type UnsetMarker
- type UnsetMutation
Constants ¶
This section is empty.
Variables ¶
var MutationImpl = []MutationImplementation{ &SetMutation{}, &PushMutation{}, &PullMutation{}, &TruncateMutation{}, &IndexMutation{}, &UnsetMutation{}, }
MutationImpl are implementations of the mutations named in MutationKeys
var MutationKeys = []string{
"$set",
"$push",
"$pull",
"$truncate",
"$mutateIdx",
"$unset",
}
MutationKeys are the string mutation keys used to represent mutations.
Functions ¶
func ApplyMutation ¶
ApplyMutation applies a mutation object to a value Note: this changes the input
func ApplyMutationObject ¶
ApplyMutationObject applies all mutations in a mutation object hierarchy recursively
func BuildMutation ¶
BuildMutation recursively builds a mutation from an old and new object.
Types ¶
type IndexMutation ¶
type IndexMutation struct {
}
IndexMutation is a MutationImplementation for $mutateIdx
func (*IndexMutation) Apply ¶
func (*IndexMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $mutateIdx mutation.
type Mutation ¶
type Mutation struct {
MutationType MutationType
}
Mutation is a wrapper class for an implementation type.
func ParseMutation ¶
ParseMutation returns a Mutation from a key like $set or nil if not found
type MutationImplementation ¶
type MutationImplementation interface {
Apply(oldVal, arg interface{}) (interface{}, error)
}
MutationImplementation represents an implementation of a mutation type
type MutationType ¶
type MutationType int
MutationType represents a type of mutator, i.e. $set
const ( // MutateSet represents the set mutation MutateSet MutationType = iota // MutatePush represents the push mutation MutatePush // MutatePull represents the pull mutation MutatePull // MutateTruncate represents the truncate mutation MutateTruncate // MutateIdx represents the index mutation MutateIdx // MutateUnset represents the unset mutation MutateUnset )
func (MutationType) String ¶
func (i MutationType) String() string
type PullMutation ¶
type PullMutation struct {
}
PullMutation is the implementation of the $pull mutation.
func (*PullMutation) Apply ¶
func (*PullMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $pull mutation.
type PushMutation ¶
type PushMutation struct {
}
PushMutation is the implementation for the $push mutation.
func (*PushMutation) Apply ¶
func (*PushMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $push mutation.
type SetMutation ¶
type SetMutation struct {
}
SetMutation is a MutationImplementation for $set
func (*SetMutation) Apply ¶
func (*SetMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $set mutation.
type TruncateMutation ¶
type TruncateMutation struct {
}
TruncateMutation is the implementation for the $truncate mutation.
func (*TruncateMutation) Apply ¶
func (*TruncateMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $truncate mutation.
type UnsetMarker ¶
type UnsetMarker struct {
}
UnsetMarker is a marker for unsetting a field returned from Apply
type UnsetMutation ¶
type UnsetMutation struct {
}
UnsetMutation is the implementation of the $unset mutation.
func (*UnsetMutation) Apply ¶
func (*UnsetMutation) Apply(oldVal, arg interface{}) (interface{}, error)
Apply the $unset mutation.