Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCouldNotUnmarshalGivenType = errors.New("could not unmarshal given type")
Functions ¶
Types ¶
type Discriminated ¶ added in v1.1.0
type Discriminated interface {
Discriminator() string
}
Represents an extensible type known through a discriminator value when implementing the Scanner interface as no sense since we don't know which type is used in our entity.
type DiscriminatedMapper ¶ added in v1.1.0
type DiscriminatedMapper[T Discriminated] map[string]DiscriminatedMapperFunc[T]
Mapper struct to be able to rehydrate discriminated types.
func NewDiscriminatedMapper ¶ added in v1.1.0
func NewDiscriminatedMapper[T Discriminated]() DiscriminatedMapper[T]
Builds a new mapper configuration to hold a discriminated type.
func (DiscriminatedMapper[T]) From ¶ added in v1.1.0
Rehydrate a discriminated type from a raw value.
func (DiscriminatedMapper[T]) Register ¶ added in v1.1.0
func (m DiscriminatedMapper[T]) Register(concreteType T, mapper DiscriminatedMapperFunc[T])
Register a new concrete type available to the mapper.
type DiscriminatedMapperFunc ¶ added in v1.1.0
type DiscriminatedMapperFunc[T Discriminated] func(string) (T, error)
Function used to map from a raw value to a discriminated type.
type Merger ¶
type Merger[TParent, TChildren any] func(TParent, TChildren) TParent // Merger function to handle relations by configuring how a child should be merged into its parent
type Scanner ¶
type Scanner interface { // Scan current row into the destination fields. // The things to keep in mind is the order used when scanning which should always be the // same as the order of fields returned by the underlying implementation (for a database, // the order of SELECT columns). // // IMPORTANT: it will fails if the type of a monad.Value is not a primitive type or // does not implements the sql.Scanner interface. Scan(...any) error }
Deserialize a storage row to field. This is the interface making possible the rehydration of domain entities from the db since all fields are private to enforce invariants and encapsulation.
Since domain store will always constructs an aggregate as a whole, it makes the process relatively easy to keep under control.