types

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DriverJSONValue

func DriverJSONValue(v any) (driver.Value, error)

DriverJSONValue unmarshal input to driver.Value

func HasSoftDeletion

func HasSoftDeletion[M internal.Model]() bool

func ScanJSONValue

func ScanJSONValue(src, dst any) error

ScanJSONValue scan database input to value

Types

type ArrayAsList added in v0.0.5

type ArrayAsList[T ArrayAsListElement] []T

func (*ArrayAsList[T]) Append added in v0.0.5

func (aa *ArrayAsList[T]) Append(values ...T)

func (*ArrayAsList[T]) AppendString added in v0.0.5

func (aa *ArrayAsList[T]) AppendString(values ...string) error

func (ArrayAsList[T]) DBType added in v0.0.5

func (aa ArrayAsList[T]) DBType(driver string) string

func (ArrayAsList[T]) Elements added in v0.0.5

func (aa ArrayAsList[T]) Elements() []string

func (*ArrayAsList[T]) MarshalJSON added in v0.0.5

func (aa *ArrayAsList[T]) MarshalJSON() ([]byte, error)

func (*ArrayAsList[T]) Scan added in v0.0.5

func (aa *ArrayAsList[T]) Scan(v any) error

func (ArrayAsList[T]) String added in v0.0.5

func (aa ArrayAsList[T]) String() string

func (*ArrayAsList[T]) UnmarshalJSON added in v0.0.5

func (aa *ArrayAsList[T]) UnmarshalJSON(data []byte) error

func (ArrayAsList[T]) Value added in v0.0.5

func (aa ArrayAsList[T]) Value() (driver.Value, error)

type ArrayAsListElement added in v0.0.5

type ArrayAsListElement interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64 |
		~string
}

type AutoIncID

type AutoIncID struct {
	ID uint64 `db:"f_id,autoinc" json:"-"`
}

type Blob

type Blob []byte

func (Blob) DBType

func (Blob) DBType(driver string) string

func (*Blob) Scan

func (v *Blob) Scan(src any) error

func (*Blob) Set

func (v *Blob) Set(x []byte)

func (Blob) Value

func (v Blob) Value() (driver.Value, error)

type Bool

type Bool int
const (
	TRUE  Bool // true
	FALSE      // false
)

func Boolean

func Boolean(b bool) Bool

func (Bool) Bool

func (v Bool) Bool() bool

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

func (Bool) MarshalText

func (v Bool) MarshalText() ([]byte, error)

func (*Bool) UnmarshalJSON

func (v *Bool) UnmarshalJSON(data []byte) (err error)

func (*Bool) UnmarshalText

func (v *Bool) UnmarshalText(data []byte) error

type CreationDatetime

type CreationDatetime struct {
	// CreatedAt 创建日期时间(秒)
	CreatedAt sqltime.Datetime `db:"f_created_at,default=CURRENT_TIMESTAMP" json:"createdAt"`
}

func (*CreationDatetime) MarkCreatedAt

func (c *CreationDatetime) MarkCreatedAt()

type CreationDatetimeMilli added in v0.0.5

type CreationDatetimeMilli struct {
	// CreatedAt 创建日期时间(毫秒)
	CreatedAt sqltime.Datetime `db:"f_created_at,precision=3,default=CURRENT_TIMESTAMP(3)" json:"createdAt"`
}

func (*CreationDatetimeMilli) MarkCreatedAt added in v0.0.5

func (c *CreationDatetimeMilli) MarkCreatedAt()

type CreationMarker

type CreationMarker interface {
	MarkCreatedAt()
}

type CreationModificationDatetime

type CreationModificationDatetime struct {
	CreationDatetime
	// UpdatedAt 更新日期时间(秒)
	UpdatedAt sqltime.Datetime `db:"f_updated_at,default=CURRENT_TIMESTAMP,onupdate=CURRENT_TIMESTAMP" json:"updatedAt"`
}

func (*CreationModificationDatetime) MarkCreatedAt

func (cu *CreationModificationDatetime) MarkCreatedAt()

func (*CreationModificationDatetime) MarkModifiedAt

func (cu *CreationModificationDatetime) MarkModifiedAt()

type CreationModificationDatetimePrecise added in v0.0.5

type CreationModificationDatetimePrecise struct {
	CreationDatetimeMilli
	// UpdatedAt 更新日期时间(毫秒)
	UpdatedAt sqltime.Datetime `db:"f_updated_at,precision=3,default=CURRENT_TIMESTAMP(3),onupdate=CURRENT_TIMESTAMP(3)" json:"updatedAt"`
}

func (*CreationModificationDatetimePrecise) MarkCreatedAt added in v0.0.5

func (cu *CreationModificationDatetimePrecise) MarkCreatedAt()

func (*CreationModificationDatetimePrecise) MarkModifiedAt added in v0.0.5

func (cu *CreationModificationDatetimePrecise) MarkModifiedAt()

type CreationModificationDeletionDatetime

type CreationModificationDeletionDatetime struct {
	CreationModificationDatetime
	// DeletedAt 删除日期时间(秒)
	DeletedAt sqltime.Datetime `db:"f_deleted_at,default='0001-01-01 00:00:00'" json:"deletedAt"`
}

func (*CreationModificationDeletionDatetime) MarkDeletedAt

func (cud *CreationModificationDeletionDatetime) MarkDeletedAt()

func (CreationModificationDeletionDatetime) SoftDeletion

type CreationModificationDeletionDatetimePrecise added in v0.0.5

type CreationModificationDeletionDatetimePrecise struct {
	CreationModificationDatetimePrecise
	// DeletedAt 删除日期时间(毫秒)
	DeletedAt sqltime.Datetime `db:"f_deleted_at,precision=3,default='0001-01-01 00:00:00.000'" json:"deletedAt"`
}

func (*CreationModificationDeletionDatetimePrecise) MarkDeletedAt added in v0.0.5

func (cud *CreationModificationDeletionDatetimePrecise) MarkDeletedAt()

func (CreationModificationDeletionDatetimePrecise) SoftDeletion added in v0.0.5

type CreationModificationDeletionTime

type CreationModificationDeletionTime struct {
	CreationModificationTime
	// DeletedAt 删除时间 秒时间戳
	DeletedAt sqltime.Timestamp `db:"f_deleted_at,default=0" json:"deletedAt,omitempty"`
}

func (*CreationModificationDeletionTime) MarkDeletedAt

func (cmd *CreationModificationDeletionTime) MarkDeletedAt()

func (CreationModificationDeletionTime) SoftDeletion

func (cmd CreationModificationDeletionTime) SoftDeletion() (string, []string, driver.Value)

type CreationModificationDeletionTimePrecise added in v0.0.5

type CreationModificationDeletionTimePrecise struct {
	CreationModificationTimePrecise
	// DeletedAt 删除时间 毫秒时间戳
	DeletedAt sqltime.TimestampMilli `db:"f_deleted_at,default=0" json:"deletedAt,omitempty"`
}

func (*CreationModificationDeletionTimePrecise) MarkDeletedAt added in v0.0.5

func (cmd *CreationModificationDeletionTimePrecise) MarkDeletedAt()

func (CreationModificationDeletionTimePrecise) SoftDeletion added in v0.0.5

type CreationModificationTime

type CreationModificationTime struct {
	CreationTime
	// UpdatedAt 更新时间 秒时间戳
	UpdatedAt sqltime.Timestamp `db:"f_updated_at,default=0" json:"updatedAt"`
}

func (*CreationModificationTime) MarkCreatedAt

func (cu *CreationModificationTime) MarkCreatedAt()

func (*CreationModificationTime) MarkModifiedAt

func (cu *CreationModificationTime) MarkModifiedAt()

type CreationModificationTimePrecise added in v0.0.5

type CreationModificationTimePrecise struct {
	CreationTimePrecise
	// UpdatedAt 更新时间 毫秒时间戳
	UpdatedAt sqltime.TimestampMilli `db:"f_updated_at,default=0" json:"updatedAt"`
}

func (*CreationModificationTimePrecise) MarkCreatedAt added in v0.0.5

func (cu *CreationModificationTimePrecise) MarkCreatedAt()

func (*CreationModificationTimePrecise) MarkModifiedAt added in v0.0.5

func (cu *CreationModificationTimePrecise) MarkModifiedAt()

type CreationTime

type CreationTime struct {
	// CreatedAt 创建时间 秒时间戳
	CreatedAt sqltime.Timestamp `db:"f_created_at,default=0" json:"createdAt"`
}

func (*CreationTime) MarkCreatedAt

func (c *CreationTime) MarkCreatedAt()

type CreationTimePrecise added in v0.0.5

type CreationTimePrecise struct {
	// CreatedAt 创建时间 毫秒时间戳
	CreatedAt sqltime.TimestampMilli `db:"f_created_at,default=0" json:"createdAt"`
}

func (*CreationTimePrecise) MarkCreatedAt added in v0.0.5

func (c *CreationTimePrecise) MarkCreatedAt()

type DBTypeAdapter

type DBTypeAdapter interface {
	WithDBType(driver string)
}

type DBValue

type DBValue interface {
	driver.Valuer
	sql.Scanner
	DBType(driver string) string
}

DBValue can convert between rdb value and go value with description of rdb datatype

type Decimal

type Decimal struct {
	decimal.Decimal
}

func AsDecimal

func AsDecimal(v decimal.Decimal) Decimal

func (*Decimal) DBType

func (d *Decimal) DBType(driver string) string

type DeletionMarker

type DeletionMarker interface {
	MarkDeletedAt()
}

type ID

type ID uint64

type JSONArray

type JSONArray[T any] struct {
	JSONDBType
	// contains filtered or unexported fields
}

func JSONArrayOf

func JSONArrayOf[T any](s []T) *JSONArray[T]

func (*JSONArray[T]) Get

func (v *JSONArray[T]) Get() []T

func (JSONArray[T]) IsZero

func (v JSONArray[T]) IsZero() bool

func (JSONArray[T]) MarshalJSON

func (v JSONArray[T]) MarshalJSON() ([]byte, error)

func (*JSONArray[T]) Scan

func (v *JSONArray[T]) Scan(src any) error

func (*JSONArray[T]) Set

func (v *JSONArray[T]) Set(x []T)

func (*JSONArray[T]) UnmarshalJSON

func (v *JSONArray[T]) UnmarshalJSON(data []byte) error

func (JSONArray[T]) Value

func (v JSONArray[T]) Value() (driver.Value, error)

type JSONDBType

type JSONDBType struct {
	// contains filtered or unexported fields
}

func (JSONDBType) DBType

func (t JSONDBType) DBType(driver string) string

func (*JSONDBType) WithDBType

func (t *JSONDBType) WithDBType(typ string)

type JSONObject

type JSONObject[T any] struct {
	JSONDBType
	// contains filtered or unexported fields
}

func JSONObjectOf

func JSONObjectOf[T any](v *T) JSONObject[T]

func (*JSONObject[T]) Get

func (v *JSONObject[T]) Get() *T

func (JSONObject[T]) IsZero

func (v JSONObject[T]) IsZero() bool

func (JSONObject[T]) MarshalJSON

func (v JSONObject[T]) MarshalJSON() ([]byte, error)

func (*JSONObject[T]) Scan

func (v *JSONObject[T]) Scan(src any) error

func (*JSONObject[T]) Set

func (v *JSONObject[T]) Set(x *T)

func (*JSONObject[T]) UnmarshalJSON

func (v *JSONObject[T]) UnmarshalJSON(data []byte) error

func (JSONObject[T]) Value

func (v JSONObject[T]) Value() (driver.Value, error)

type ModificationMarker

type ModificationMarker interface {
	MarkModifiedAt()
}

type OperationDatetimePrecise added in v0.0.5

type OperationDatetimePrecise = CreationModificationDeletionDatetimePrecise

type OperationTimePrecise added in v0.0.5

type OperationTimePrecise = CreationModificationDeletionTimePrecise

type SoftDeletion

type SoftDeletion interface {
	// SoftDeletion returns soft deletion field name, modifications fields if exists
	// and default value of deletion field
	SoftDeletion() (deletion string, modifications []string, v driver.Value)
}

type Text

type Text string

func (Text) DBType

func (Text) DBType(driver string) string

func (*Text) Scan

func (v *Text) Scan(src any) error

func (*Text) Set

func (v *Text) Set(str string)

func (Text) Value

func (v Text) Value() (driver.Value, error)

Directories

Path Synopsis