delta

package
v0.24.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slice

type Slice[T comparable] struct {
	Values  []T `json:"values" bson:"values"`
	Added   []T `json:"-"      bson:"-"`
	Deleted []T `json:"-"      bson:"-"`
}

Slice tracks changes to a slice of generic values. As items are added or removed from the slice, they are tracked in the "Added" and "Deleted" lists.

func NewSlice

func NewSlice[T comparable](values ...T) Slice[T]

NewSlice returns a fully initialized Slice object

func (Slice[T]) GetValue

func (s Slice[T]) GetValue() any

GetValue implements schema.ValueGetter and returns the current value

func (Slice[T]) IsChanged

func (s Slice[T]) IsChanged() bool

IsChanged returns TRUE if the slice has been modified

func (Slice[T]) Length

func (s Slice[T]) Length() int

Length returns the number of keys in the map

func (Slice[T]) MarshalJSON

func (s Slice[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface and serializes the Slice into a JSON array

func (*Slice[T]) Reset

func (s *Slice[T]) Reset()

Reset resets all of the added/deleted values

func (*Slice[T]) SetValue

func (s *Slice[T]) SetValue(value any) error

SetValue implements schema.ValueSetter and updates the current value, tracking changes to the added and deleted lists.

func (*Slice[T]) UnmarshalJSON

func (s *Slice[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface and deserializes the Slice from a JSON array

Jump to

Keyboard shortcuts

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