states

package
v0.0.0-...-e65fa06 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Types

type DatabaseState

type DatabaseState struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	VersionID uint64         `gorm:"autoIncrement"` // unique
	Timestamp time.Time      `gorm:"index"`
	Name      string         `gorm:"index"`
	EntityID  string         `gorm:"index"`
	Data      pgtype.JSONB   `gorm:"type:jsonb"`
}

func GetAll

func GetAll(db *gorm.DB) ([]*DatabaseState, error)

func (*DatabaseState) Create

func (d *DatabaseState) Create(givenDB *gorm.DB) (*gorm.DB, error)

func (*DatabaseState) Delete

func (d *DatabaseState) Delete(givenDB *gorm.DB) (*gorm.DB, error)

func (*DatabaseState) TableName

func (d *DatabaseState) TableName() string

func (*DatabaseState) Update

func (d *DatabaseState) Update(givenDB *gorm.DB) (*gorm.DB, error)

type State

type State struct {
	VersionID uint64          `json:"version_id"`
	Timestamp time.Time       `json:"timestamp"`
	Name      string          `json:"name"`
	EntityID  ksuid.KSUID     `json:"entity_id"`
	Data      json.RawMessage `json:"data"`
}

func FromJSON

func FromJSON(data []byte) (*State, error)

func New

func New(name string, entityID ksuid.KSUID, data json.RawMessage) *State

func (*State) FromJSON

func (s *State) FromJSON(data []byte) error

func (*State) String

func (s *State) String() string

func (*State) ToDatabaseState

func (s *State) ToDatabaseState() (*DatabaseState, error)

func (*State) ToJSON

func (s *State) ToJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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