model

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const NilUIntID = 0

Variables

View Source
var NilUUID = UUID(uuid.Nil)

Functions

This section is empty.

Types

type ID

type ID interface {
	UIntID | UUID

	IsNil() bool
}

supported types for model identifier

type Model

type Model interface {
	IsLoaded() bool
}

type UIntID

type UIntID uint

func (UIntID) IsNil

func (id UIntID) IsNil() bool

type UIntModel

type UIntModel struct {
	ID        UIntID `gorm:"primarykey;not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (UIntModel) IsLoaded

func (model UIntModel) IsLoaded() bool

type UUID

type UUID uuid.UUID

func NewUUID

func NewUUID() UUID

func ParseUUID

func ParseUUID(s string) (UUID, error)

func (UUID) ClockSequence

func (id UUID) ClockSequence() int

func (UUID) GormDBDataType

func (id UUID) GormDBDataType(db *gorm.DB, _ *schema.Field) string

func (UUID) GormValue

func (id UUID) GormValue(_ context.Context, db *gorm.DB) clause.Expr

func (UUID) IsNil

func (id UUID) IsNil() bool

func (UUID) MarshalBinary

func (id UUID) MarshalBinary() ([]byte, error)

func (UUID) MarshalText

func (id UUID) MarshalText() ([]byte, error)

func (*UUID) Scan

func (id *UUID) Scan(src interface{}) error

func (UUID) String

func (id UUID) String() string

func (UUID) Time

func (id UUID) Time() uuid.Time

func (UUID) URN

func (id UUID) URN() string

func (*UUID) UnmarshalBinary

func (id *UUID) UnmarshalBinary(data []byte) error

func (*UUID) UnmarshalText

func (id *UUID) UnmarshalText(data []byte) error

func (UUID) Value

func (id UUID) Value() (driver.Value, error)

func (UUID) Variant

func (id UUID) Variant() uuid.Variant

func (UUID) Version

func (id UUID) Version() uuid.Version

type UUIDModel

type UUIDModel struct {
	ID        UUID `gorm:"primarykey;not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Base Model for gorm

Every model intended to be saved in the database must embed this UUIDModel or UIntModel reference: https://gorm.io/docs/models.html#gorm-Model

func (*UUIDModel) BeforeCreate

func (model *UUIDModel) BeforeCreate(_ *gorm.DB) (err error)

func (UUIDModel) IsLoaded

func (model UUIDModel) IsLoaded() bool

Jump to

Keyboard shortcuts

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