entity

package
v0.0.0-...-52eab8c Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDynamodb_Map

func ToDynamodb_Map(entity Entity) (map[string]types.AttributeValue, error)

Types

type Creation

type Creation interface {
	SetEvent(
		eventType string,
		eventVersion uint64,
		eventData interface{},
	) Creation

	Execute() Entity
}

func Create

func Create(ctx context.Context, state interface{}) Creation

type Deletion

type Deletion interface {
	SetEvent(
		eventType string,
		eventVersion uint64,
		eventData interface{},
	) Deletion

	Execute() Entity
}

type Entity

type Entity interface {
	ID() string
	Type() string
	Version() uint64
	Indexes() []string
	Status() EntityStatus
	Data(interface{}) error
	UpdatedAt() time.Time
	UpdatedBy() string
	CreatedAt() time.Time
	CreatedBy() string
	LastEvent() (message.Event, error)
	Mutate(ctx context.Context, newState interface{}) Mutation
	Delete(ctx context.Context) Deletion
}

func FindOne

func FindOne(ctx context.Context, props *FindOneProps) (Entity, error)

func FromDynamodb_StreamMap

func FromDynamodb_StreamMap(input map[string]streamtypes.AttributeValue) (Entity, error)

func FromDynamodb_TableMap

func FromDynamodb_TableMap(input map[string]tabletypes.AttributeValue) (Entity, error)

func FromJson

func FromJson(input []byte) (Entity, error)

func FromStream

func FromStream(input events.DynamoDBEventRecord) (Entity, error)

type EntityPage

type EntityPage interface {
	Items() []Entity
	NextToken() string
}

func FindAll

func FindAll(ctx context.Context, props *FindAllProps) (EntityPage, error)

func FindBy

func FindBy(ctx context.Context, props *FindByProps) (EntityPage, error)

func NewPage

func NewPage(entities []Entity, nextToken string) EntityPage

type EntityStatus

type EntityStatus string
const (
	EntityStatus_Alive EntityStatus = "alive"
	EntityStatus_Dead  EntityStatus = "dead"
)

type FindAllProps

type FindAllProps struct {
	Domain    string `field:"required"`
	Typename  string `field:"required"`
	NextToken string `field:"optional"`
	Limit     uint64 `field:"optional"`
}

type FindByProps

type FindByProps struct {
	Domain     string `field:"required"`
	Typename   string `field:"required"`
	IndexName  string `field:"required"`
	IndexValue string `field:"required"`
	NextToken  string `field:"optional"`
	Limit      uint64 `field:"optional"`
}

type FindOneProps

type FindOneProps struct {
	Domain   string `field:"required"`
	Typename string `field:"required"`
	ID       string `field:"required"`
}

type Mutation

type Mutation interface {
	SetEvent(
		eventType string,
		eventVersion uint64,
		eventData interface{},
	) Mutation

	Execute() Entity
}

Jump to

Keyboard shortcuts

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