model

package
v0.0.0-...-d364ca2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package model provides Soro's persistence model primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID          uuid.UUID  `bun:"id,pk,type:uuid" json:"id"`
	Name        string     `bun:"name,type:varchar(255)" json:"name"`
	Description string     `bun:"description,type:text" json:"description"`
	Metadata    Metadata   `bun:"metadata,type:jsonb,notnull,default:'{}'" json:"metadata"`
	CreatedAt   time.Time  `bun:"created_at,type:timestamptz,notnull" json:"created_at"`
	UpdatedAt   time.Time  `bun:"updated_at,type:timestamptz,notnull" json:"updated_at"`
	DeletedAt   *time.Time `bun:"deleted_at,type:timestamptz,nullzero" json:"deleted_at,omitempty"`
	CreatedBy   *uuid.UUID `bun:"created_by,type:uuid,nullzero" json:"created_by,omitempty"`
	UpdatedBy   *uuid.UUID `bun:"updated_by,type:uuid,nullzero" json:"updated_by,omitempty"`
	DeletedBy   *uuid.UUID `bun:"deleted_by,type:uuid,nullzero" json:"deleted_by,omitempty"`
}

Base is embedded by normal Soro models. IDs are generated by repositories as UUIDv7 values before lifecycle validation begins.

func (*Base) SoroBase

func (b *Base) SoroBase() *Base

SoroBase makes embedding Base an explicit repository contract.

type Entity

type Entity interface {
	SoroBase() *Base
}

Entity is implemented by pointers to structs that embed Base.

type Metadata

type Metadata map[string]any

Metadata is arbitrary JSON object data persisted as PostgreSQL JSONB.

func (Metadata) Delete

func (m Metadata) Delete(key string)

func (Metadata) Get

func (m Metadata) Get(key string) (any, bool)

func (Metadata) GetBool

func (m Metadata) GetBool(key string) (bool, error)

func (Metadata) GetInt

func (m Metadata) GetInt(key string) (int, error)

func (Metadata) GetString

func (m Metadata) GetString(key string) (string, error)

func (Metadata) Has

func (m Metadata) Has(key string) bool

func (*Metadata) Scan

func (m *Metadata) Scan(src any) error

func (*Metadata) Set

func (m *Metadata) Set(key string, value any)

func (Metadata) Value

func (m Metadata) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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