storage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotUnmarshalGivenType = errors.New("could not unmarshal given type")

Functions

func ScanJSON

func ScanJSON[T any](value any, target *T) error

Ease the scan of a json serialized field.

Types

type KeyedMapper

type KeyedMapper[T any, TScanner Scanner] func(TScanner) (string, T, error) // Mapper function returning a key needed to merge related data

type Mapper

type Mapper[T any] func(Scanner) (T, error) // Mapper function from a simple Scanner to an object of type T

type Merger

type Merger[TParent, TChildren any] func(TParent, TChildren) TParent // Merger function to handle relations by configuring how an item should be merged

type Paginated

type Paginated[T any] struct {
	Data        []T  `json:"data"`
	Page        int  `json:"page"`
	IsFirstPage bool `json:"first_page"`
	IsLastPage  bool `json:"last_page"`
	PerPage     int  `json:"per_page"`
	Total       int  `json:"total"`
}

Represents paginated data set.

type Scanner

type 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.

The things to keep in mind is the order used when scanning which should always be the same.

IMPORTANT: it will fails if the type of a monad.Value is not a primitive type or does not implements the sql.Scanner interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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