types

package
v0.2.8-rc6 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package types defines types for SQL. +genx:doc

Code generated by genx:doc DO NOT EDIT.

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]) DocOf added in v0.2.8

func (v *ArrayAsList[T]) DocOf(names ...string) ([]string, bool)

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

func (*AutoIncID) DocOf added in v0.2.8

func (v *AutoIncID) DocOf(names ...string) ([]string, bool)

type Blob

type Blob []byte

Blob nullable binary

func (Blob) DBType

func (Blob) DBType(driver string) string

func (*Blob) DocOf added in v0.2.8

func (v *Blob) DocOf(names ...string) ([]string, bool)

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

Bool a ternary boolean state UNKNOWN, TRUE or FALSE

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

func Boolean

func Boolean(b bool) Bool

func (Bool) Bool

func (v Bool) Bool() bool

func (*Bool) DocOf added in v0.2.8

func (v *Bool) DocOf(names ...string) ([]string, bool)

func (Bool) MarshalJSON

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

func (Bool) MarshalText

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

func (Bool) OpenAPISchemaType added in v0.2.8

func (Bool) OpenAPISchemaType() []string

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) DocOf added in v0.2.8

func (v *CreationDatetime) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationDatetimeMilli) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationModificationDatetime) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationModificationDatetimePrecise) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationModificationDeletionDatetime) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

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

func (*CreationModificationDeletionTime) DocOf added in v0.2.8

func (v *CreationModificationDeletionTime) DocOf(names ...string) ([]string, bool)

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

func (*CreationModificationDeletionTimePrecise) DocOf added in v0.2.8

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) DocOf added in v0.2.8

func (v *CreationModificationTime) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationModificationTimePrecise) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationTime) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *CreationTimePrecise) DocOf(names ...string) ([]string, bool)

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
}

Decimal decimal number

func AsDecimal

func AsDecimal(v decimal.Decimal) Decimal

func (*Decimal) DBType

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

func (*Decimal) DocOf added in v0.2.8

func (v *Decimal) DocOf(names ...string) ([]string, bool)

func (Decimal) OpenAPISchemaFormat added in v0.2.8

func (Decimal) OpenAPISchemaFormat() string

func (Decimal) OpenAPISchemaType added in v0.2.8

func (Decimal) OpenAPISchemaType() []string

type DeletionMarker

type DeletionMarker interface {
	MarkDeletedAt()
}

type ID

type ID uint64

func (*ID) DocOf added in v0.2.8

func (v *ID) DocOf(names ...string) ([]string, bool)

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]) DocOf added in v0.2.8

func (v *JSONArray[T]) DocOf(names ...string) ([]string, bool)

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) DocOf added in v0.2.8

func (v *JSONDBType) DocOf(names ...string) ([]string, bool)

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]) DocOf added in v0.2.8

func (v *JSONObject[T]) DocOf(names ...string) ([]string, bool)

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

Text nullable text

func (Text) DBType

func (Text) DBType(driver string) string

func (*Text) DocOf added in v0.2.8

func (v *Text) DocOf(names ...string) ([]string, bool)

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
Package sqlops +genx:doc
Package sqlops +genx:doc

Jump to

Keyboard shortcuts

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