Documentation
¶
Index ¶
- Variables
- func AddTimeInputLayouts(layouts ...string)
- func DriverJSONValue(v any) (driver.Value, error)
- func GetTimeInputLayouts() []string
- func GetTimeOutputLayout() string
- func GetTimezone() *time.Location
- func HasSoftDeletion[M internal.Model]() bool
- func ScanJSONValue(src, dst any) error
- func SetTimeOutputLayout(layout string)
- func SetTimezone(timezone *time.Location)
- type AutoIncID
- type Blob
- type Bool
- type CreationDatetime
- type CreationMarker
- type CreationModificationDatetime
- type CreationModificationDeletionDatetime
- type CreationModificationDeletionTime
- type CreationModificationTime
- type CreationTime
- type DBTypeAdapter
- type DBValue
- type Datetime
- type Decimal
- type DeletionMarker
- type ID
- type JSONArray
- func (v *JSONArray[T]) Get() []T
- func (v JSONArray[T]) IsZero() bool
- func (v JSONArray[T]) MarshalJSON() ([]byte, error)
- func (v *JSONArray[T]) Scan(src any) error
- func (v *JSONArray[T]) Set(x []T)
- func (v *JSONArray[T]) UnmarshalJSON(data []byte) error
- func (v JSONArray[T]) Value() (driver.Value, error)
- type JSONDBType
- type JSONObject
- func (v *JSONObject[T]) Get() *T
- func (v JSONObject[T]) IsZero() bool
- func (v JSONObject[T]) MarshalJSON() ([]byte, error)
- func (v *JSONObject[T]) Scan(src any) error
- func (v *JSONObject[T]) Set(x *T)
- func (v *JSONObject[T]) UnmarshalJSON(data []byte) error
- func (v JSONObject[T]) Value() (driver.Value, error)
- type ModificationMarker
- type OperationDatetime
- type OperationTime
- type SoftDeletion
- type Text
- type Timestamp
- func (Timestamp) DBType(driver string) string
- func (t Timestamp) Format(layout string) string
- func (t Timestamp) Int() int64
- func (t Timestamp) IsZero() bool
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t Timestamp) MarshalText() ([]byte, error)
- func (t *Timestamp) Scan(src any) error
- func (t Timestamp) String() string
- func (t *Timestamp) UnmarshalJSON(data []byte) error
- func (t *Timestamp) UnmarshalText(data []byte) error
- func (t Timestamp) Unwrap() time.Time
- func (t Timestamp) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DatetimeZero = Datetime{Timestamp: TimestampZero} DatetimeUnixZero = Datetime{Timestamp: TimestampUnixZero} )
View Source
var ( UTC = time.UTC // CST Chinese Standard Timezone CST = must.NoErrorV(time.LoadLocation("Asia/Shanghai")) // JST Japan Standard Timezone JST = must.NoErrorV(time.LoadLocation("Asia/Tokyo")) // KST Korea Standard Timezone KST = must.NoErrorV(time.LoadLocation("Asia/Seoul")) // IST Indochina Standard Timezone (Thailand) IST = must.NoErrorV(time.LoadLocation("Asia/Bangkok")) TimestampZero = Timestamp{time.Time{}} TimestampUnixZero = Timestamp{time.Unix(0, 0)} DefaultTimeLayout = "2006-01-02 15:04:05.000" )
Functions ¶
func AddTimeInputLayouts ¶
func AddTimeInputLayouts(layouts ...string)
func DriverJSONValue ¶
DriverJSONValue unmarshal input to driver.Value
func GetTimeInputLayouts ¶
func GetTimeInputLayouts() []string
func GetTimeOutputLayout ¶
func GetTimeOutputLayout() string
func GetTimezone ¶
func HasSoftDeletion ¶
func ScanJSONValue ¶
ScanJSONValue scan database input to value
func SetTimeOutputLayout ¶
func SetTimeOutputLayout(layout string)
func SetTimezone ¶
Types ¶
type Bool ¶
type Bool int
const ( TRUE Bool // true FALSE // false )
func (Bool) MarshalJSON ¶
func (Bool) MarshalText ¶
func (*Bool) UnmarshalJSON ¶
func (*Bool) UnmarshalText ¶
type CreationDatetime ¶
type CreationDatetime struct {
// CreatedAt 创建日期时间(毫秒)
CreatedAt Datetime `db:"f_created_at,precision=3,default=CURRENT_TIMESTAMP(3)" json:"createdAt"`
}
func (*CreationDatetime) MarkCreatedAt ¶
func (c *CreationDatetime) MarkCreatedAt()
type CreationMarker ¶
type CreationMarker interface {
MarkCreatedAt()
}
type CreationModificationDatetime ¶
type CreationModificationDatetime struct {
CreationDatetime
// UpdatedAt 更新日期时间(毫秒)
UpdatedAt Datetime `db:"f_updated_at,precision=3,default=CURRENT_TIMESTAMP(3),onupdate=CURRENT_TIMESTAMP(3)" json:"updatedAt"`
}
func (*CreationModificationDatetime) MarkCreatedAt ¶
func (cu *CreationModificationDatetime) MarkCreatedAt()
func (*CreationModificationDatetime) MarkModifiedAt ¶
func (cu *CreationModificationDatetime) MarkModifiedAt()
type CreationModificationDeletionDatetime ¶
type CreationModificationDeletionDatetime struct {
CreationModificationDatetime
// DeletedAt 删除日期时间(毫秒)
DeletedAt Datetime `db:"f_deleted_at,precision=3,default='0001-01-01 00:00:00.000'" json:"deletedAt"`
}
func (*CreationModificationDeletionDatetime) MarkDeletedAt ¶
func (cud *CreationModificationDeletionDatetime) MarkDeletedAt()
func (CreationModificationDeletionDatetime) SoftDeletion ¶
func (cud CreationModificationDeletionDatetime) SoftDeletion() (string, []string, driver.Value)
type CreationModificationDeletionTime ¶
type CreationModificationDeletionTime struct {
CreationModificationTime
// DeletedAt 删除时间 毫秒时间戳
DeletedAt 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 CreationModificationTime ¶
type CreationModificationTime struct {
CreationTime
// UpdatedAt 更新时间 毫秒时间戳
UpdatedAt Timestamp `db:"f_updated_at,default='0'" json:"updatedAt"`
}
func (*CreationModificationTime) MarkCreatedAt ¶
func (cu *CreationModificationTime) MarkCreatedAt()
func (*CreationModificationTime) MarkModifiedAt ¶
func (cu *CreationModificationTime) MarkModifiedAt()
type CreationTime ¶
type CreationTime struct {
// CreatedAt 创建时间 毫秒时间戳
CreatedAt Timestamp `db:"f_created_at,default='0'" json:"createdAt"`
}
func (*CreationTime) MarkCreatedAt ¶
func (c *CreationTime) MarkCreatedAt()
type DBTypeAdapter ¶
type DBTypeAdapter interface {
WithDBType(driver string)
}
type DeletionMarker ¶
type DeletionMarker interface {
MarkDeletedAt()
}
type JSONArray ¶
type JSONArray[T any] struct { JSONDBType // contains filtered or unexported fields }
func JSONArrayOf ¶
func (JSONArray[T]) MarshalJSON ¶
func (*JSONArray[T]) UnmarshalJSON ¶
type JSONDBType ¶
type JSONDBType struct {
// contains filtered or unexported fields
}
func (JSONDBType) DBType ¶
func (t JSONDBType) DBType() 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
type ModificationMarker ¶
type ModificationMarker interface {
MarkModifiedAt()
}
type OperationDatetime ¶
type OperationDatetime = CreationModificationDeletionDatetime
type OperationTime ¶
type OperationTime = CreationModificationDeletionTime
type SoftDeletion ¶
type Timestamp ¶
func AsTimestamp ¶
func ParseTimestamp ¶
func (Timestamp) MarshalJSON ¶
func (Timestamp) MarshalText ¶
func (*Timestamp) UnmarshalJSON ¶
func (*Timestamp) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.