model

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MPL-2.0 Imports: 7 Imported by: 3

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
	SoftDeleteColumnName() string
	UpdatedAtColumnName() string
}

type UIntID

type UIntID uint

func (UIntID) IsNil

func (id UIntID) IsNil() bool

type UIntModel

type UIntModel struct {
	ID UIntID `gorm:"primarykey;not null"`
}

Base Model for cql with uint as id

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

func (UIntModel) IsLoaded

func (model UIntModel) IsLoaded() bool

func (UIntModel) SoftDeleteColumnName added in v0.6.0

func (model UIntModel) SoftDeleteColumnName() string

func (UIntModel) UpdatedAtColumnName added in v0.6.0

func (model UIntModel) UpdatedAtColumnName() string

type UIntModelWithTimestamps added in v0.6.0

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

Base Model for cql with uint as id and timestamps for creation, edition and deletion (soft-delete)

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

func (UIntModelWithTimestamps) IsLoaded added in v0.6.0

func (model UIntModelWithTimestamps) IsLoaded() bool

func (UIntModelWithTimestamps) SoftDeleteColumnName added in v0.6.0

func (model UIntModelWithTimestamps) SoftDeleteColumnName() string

func (UIntModelWithTimestamps) UpdatedAtColumnName added in v0.6.0

func (model UIntModelWithTimestamps) UpdatedAtColumnName() string

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"`
}

Base Model for cql with uuid as id and timestamps for creation, edition and deletion (soft-delete)

Every model intended to be saved in the database must embed UUIDModel, UUIDModelWithTimestamps, UIntModel or UIntModelWithTimestamps 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

func (UUIDModel) SoftDeleteColumnName added in v0.6.0

func (model UUIDModel) SoftDeleteColumnName() string

func (UUIDModel) UpdatedAtColumnName added in v0.6.0

func (model UUIDModel) UpdatedAtColumnName() string

type UUIDModelWithTimestamps added in v0.6.0

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

Base Model for cql with uuid as id and timestamps for creation, edition and deletion (soft-delete)

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

func (*UUIDModelWithTimestamps) BeforeCreate added in v0.6.0

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

func (UUIDModelWithTimestamps) IsLoaded added in v0.6.0

func (model UUIDModelWithTimestamps) IsLoaded() bool

func (UUIDModelWithTimestamps) SoftDeleteColumnName added in v0.6.0

func (model UUIDModelWithTimestamps) SoftDeleteColumnName() string

func (UUIDModelWithTimestamps) UpdatedAtColumnName added in v0.6.0

func (model UUIDModelWithTimestamps) UpdatedAtColumnName() string

Jump to

Keyboard shortcuts

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