entity

package
v2.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	ID        ids.Id    `json:"id" bson:"_id"`
	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
	Version   int       `json:"version" bson:"version"`
	Tenant    string    `json:"tenant,omitempty" bson:"tenant,omitempty"`
}

Metadata is the metadata for any entity.

func FromEvent added in v2.1.0

func FromEvent(event eh.Event) Metadata

FromEvent creates an entity metadata from the EventHorizon event

func New

func New(options ...Option) Metadata

func (Metadata) Clone

func (e Metadata) Clone(now time.Time) Metadata

Clone returns a clone of the entity with a new ID and CreatedAt if necessary. Updates UpdatedAt.

func (Metadata) CloneIn

func (e Metadata) CloneIn(ctx context.Context, now time.Time) Metadata

func (Metadata) GetID

func (e Metadata) GetID() ids.Id

GetID returns the ID of the entity. Implements Identifiable interfaces.

func (Metadata) GetTenant

func (e Metadata) GetTenant() string

type Option

type Option func(m *Metadata)

func At

func At(t time.Time) Option

func WithCtx

func WithCtx(ctx context.Context) Option

func WithId

func WithId(id ids.Id) Option

func WithTenant

func WithTenant(tenant string) Option

type Updatable added in v2.2.0

type Updatable interface {
	// UpdateMetadata updates the metadata of the entity before saving to repository. Returns the updated metadata.
	UpdateMetadata(ctx context.Context)
}

Updatable is an interface for entities that can update their metadata before saving to repository

Jump to

Keyboard shortcuts

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