Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiffByID ¶
func DiffByID[T Entity](input DiffByIDInput[T]) error
DiffByID compares the expected state with the db state by ID.
The callback functions are used to allow for custom handling of the diff entries.
The call does not compare the entities themselves, it only compares the IDs. Can be used for entities that have child entities.
Types ¶
type Diff ¶
type Diff[T Entity] struct { Update []DiffUpdate[T] Create []T Delete []T }
func DiffByIDEqualer ¶
func DiffByIDEqualer[T EqualerEntity[T]](expectedState, dbState []T) Diff[T]
DiffByIDEqualer compares the expected state with the db state by ID.
This call uses the Equal method of the entity to compare the expected state with the db state in case of updates.
Should be used for entities that do not have any child entities.
func (*Diff[T]) NeedsCreate ¶
func (d *Diff[T]) NeedsCreate(item ...T)
func (*Diff[T]) NeedsDelete ¶
func (d *Diff[T]) NeedsDelete(item ...T)
func (*Diff[T]) NeedsUpdate ¶
func (d *Diff[T]) NeedsUpdate(item ...DiffUpdate[T])
type DiffByIDInput ¶
type DiffByIDInput[T Entity] struct { DBState []T ExpectedState []T HandleDelete func(item T) error HandleCreate func(item T) error HandleUpdate func(item DiffUpdate[T]) error }
type DiffUpdate ¶
type DiffUpdate[T Entity] struct { // PersistedState is the persisted state of the entity (e.g. in database or any storage), if empty there is no persisted state PersistedState T // ExpectedState is the expected state of the entity (e.g. after the changes done by the backend) ExpectedState T }
type EqualerNestedEntity ¶
type EqualerNestedEntity[T EqualerEntity[T], P Entity] struct { Entity T Parent P }
func NewEqualersWithParent ¶
func NewEqualersWithParent[T EqualerEntity[T], P Entity](entity []T, parent P) []EqualerNestedEntity[T, P]
func (EqualerNestedEntity[T, P]) Equal ¶
func (w EqualerNestedEntity[T, P]) Equal(other EqualerNestedEntity[T, P]) bool
func (EqualerNestedEntity[T, P]) GetID ¶
func (w EqualerNestedEntity[T, P]) GetID() string
func (EqualerNestedEntity[T, P]) IsDeleted ¶
func (w EqualerNestedEntity[T, P]) IsDeleted() bool
type NestedEntity ¶
func (NestedEntity[T, P]) GetID ¶
func (w NestedEntity[T, P]) GetID() string
func (NestedEntity[T, P]) IsDeleted ¶
func (w NestedEntity[T, P]) IsDeleted() bool
Click to show internal directories.
Click to hide internal directories.