Documentation
¶
Overview ¶
Package spectypes provides nullable SQL types with automatic casting and conversion methods.
Index ¶
- func ToJSONDT(dt time.Time) string
- func TryIfInt64(v any, def int64) int64
- type SqlBool
- type SqlDate
- type SqlFloat64
- type SqlInt16
- type SqlInt32
- type SqlInt64
- type SqlJSONB
- type SqlNull
- func (n SqlNull[T]) Bool() bool
- func (n SqlNull[T]) Float64() float64
- func (n *SqlNull[T]) FromString(s string) error
- func (n SqlNull[T]) Int64() int64
- func (n SqlNull[T]) MarshalJSON() ([]byte, error)
- func (n *SqlNull[T]) Scan(value any) error
- func (n SqlNull[T]) String() string
- func (n SqlNull[T]) Time() time.Time
- func (n SqlNull[T]) UUID() uuid.UUID
- func (n *SqlNull[T]) UnmarshalJSON(b []byte) error
- func (n SqlNull[T]) Value() (driver.Value, error)
- type SqlString
- type SqlTime
- type SqlTimeStamp
- type SqlUUID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TryIfInt64 ¶
TryIfInt64 tries to parse any value to int64 with default.
Types ¶
type SqlDate ¶
SqlDate - Date only (YYYY-MM-DD).
func NewSqlDate ¶
func SqlDateNow ¶
func SqlDateNow() SqlDate
func (SqlDate) MarshalJSON ¶
func (*SqlDate) UnmarshalJSON ¶
type SqlFloat64 ¶
Type aliases for common types.
func NewSqlFloat64 ¶
func NewSqlFloat64(v float64) SqlFloat64
type SqlJSONB ¶
type SqlJSONB []byte
SqlJSONB - Nullable JSONB as []byte.
func (SqlJSONB) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*SqlJSONB) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type SqlNull ¶
SqlNull is a generic nullable type that behaves like sql.NullXXX with auto-casting.
func (*SqlNull[T]) FromString ¶
func (SqlNull[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*SqlNull[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type SqlTime ¶
SqlTime - Time only (HH:MM:SS).
func NewSqlTime ¶
func SqlTimeNow ¶
func SqlTimeNow() SqlTime
func (SqlTime) MarshalJSON ¶
func (*SqlTime) UnmarshalJSON ¶
type SqlTimeStamp ¶
SqlTimeStamp - Timestamp with custom formatting (YYYY-MM-DDTHH:MM:SS).
func NewSqlTimeStamp ¶
func NewSqlTimeStamp(v time.Time) SqlTimeStamp
func SqlTimeStampNow ¶
func SqlTimeStampNow() SqlTimeStamp
func (SqlTimeStamp) MarshalJSON ¶
func (t SqlTimeStamp) MarshalJSON() ([]byte, error)
func (*SqlTimeStamp) UnmarshalJSON ¶
func (t *SqlTimeStamp) UnmarshalJSON(b []byte) error
Click to show internal directories.
Click to hide internal directories.