datatype

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeletedAt

type DeletedAt int64

DeletedAt 使用 0 表示有效记录,使用 Unix 毫秒时间戳表示已删除记录。

func (DeletedAt) DeleteClauses

func (DeletedAt) DeleteClauses(field *schema.Field) []clause.Interface

func (DeletedAt) GormDBDataType

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

func (DeletedAt) GormDataType

func (DeletedAt) GormDataType() string

func (DeletedAt) MarshalJSON

func (x DeletedAt) MarshalJSON() ([]byte, error)

func (DeletedAt) QueryClauses

func (DeletedAt) QueryClauses(field *schema.Field) []clause.Interface

func (*DeletedAt) Scan

func (x *DeletedAt) Scan(value any) error

func (*DeletedAt) UnmarshalJSON

func (x *DeletedAt) UnmarshalJSON(bytes []byte) error

func (DeletedAt) UpdateClauses

func (DeletedAt) UpdateClauses(field *schema.Field) []clause.Interface

func (DeletedAt) Value

func (x DeletedAt) Value() (driver.Value, error)

type Field

type Field interface {
	sql.Scanner
	driver.Valuer

	json.Marshaler
	json.Unmarshaler
}

type JSON

type JSON json.RawMessage

JSON 是可直接持久化并通过 gjson 路径读取的原始 JSON 文档。

func (JSON) Get

func (x JSON) Get(path string) gjson.Result

Get 使用 gjson 路径语法读取文档中的值。

func (JSON) GormDBDataType

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

func (JSON) GormDataType

func (JSON) GormDataType() string

func (JSON) GormValue

func (x JSON) GormValue(_ context.Context, db *gorm.DB) clause.Expr

func (JSON) MarshalJSON

func (x JSON) MarshalJSON() ([]byte, error)

func (JSON) MustUnmarshal added in v1.0.5

func (x JSON) MustUnmarshal[T any]() T

MustUnmarshal 行为与 Unmarshal 一致,但失败时 panic 并由 core/codec/json 统一打印调用堆栈, 仅适用于文档格式已在初始化阶段保证正确的场景。

func (JSON) Parse

func (x JSON) Parse() gjson.Result

Parse 将完整文档解析为可继续查询的 gjson Result。

func (*JSON) Scan

func (x *JSON) Scan(value any) error

Scan 从数据库读取 JSON,并复制驱动可能复用的字节缓冲区。

func (JSON) String

func (x JSON) String() string

func (JSON) Unmarshal added in v1.0.5

func (x JSON) Unmarshal[T any]() (t T, err error)

Unmarshal 使用 core/codec/json 将文档反序列化为类型 T,文档不完整或与 T 结构不匹配时返回错误, 失败时保持 T 的零值。

func (*JSON) UnmarshalJSON

func (x *JSON) UnmarshalJSON(bytes []byte) error

func (JSON) Valid

func (x JSON) Valid() bool

Valid 判断当前值是否为完整且合法的 JSON 文档。

func (JSON) Value

func (x JSON) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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