Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedType = errors.New("unsupported type")
Functions ¶
This section is empty.
Types ¶
type JSON ¶ added in v0.2.0
func (JSON[T]) MarshalJSON ¶ added in v0.2.1
func (*JSON[T]) UnmarshalJSON ¶ added in v0.2.1
type Map ¶
func (*Map[T]) UnmarshalJSON ¶ added in v0.4.1
type Null ¶ added in v0.2.3
type Null[T any] struct { sql.Null[T] // ParsedNull is a helper field to distinguish between a null value and an omitted field during JSON unmarshalling. // - if the field is present in the JSON (even if it's null), ParsedNull will be true. ParsedNull bool `json:"-"` }
func NewNull ¶ added in v0.2.5
NewNull creates a Null[T] with the given value and Valid set to true.
func NewNullFromPtr ¶ added in v0.4.5
NewNullFromPtr creates a Null[T] from a pointer to T.
- If the pointer is nil, it returns a Null[T] with Valid set to false and V set to the zero value of T.
func NewNullWithValid ¶ added in v0.4.5
NewNullWithValid creates a Null[T] with the given value and Valid set to the specified boolean.
func NewTimeNullWithValid ¶ added in v0.4.8
func (Null[T]) MarshalJSON ¶ added in v0.2.3
func (*Null[T]) Merge ¶ added in v0.6.1
Merge merges the current Null[T] with an old one, preserving the old value if the current one is not valid and not explicitly set to null.
This relies on types.Null's ParsedNull marker, which captures what a plain Go zero value cannot: whether the client said "leave this alone" or "make this empty".
func (*Null[T]) Present ¶ added in v0.6.1
Present reports whether the field was in the update JSON at all, with either a value or an explicit null. Use it when a merge is not a straight replacement — a secret that is kept unless explicitly cleared, say.
func (Null[T]) Ptr ¶ added in v0.4.3
func (n Null[T]) Ptr() *T
Ptr returns a pointer to the inner value if Valid is true, otherwise it returns nil.
func (*Null[T]) UnmarshalJSON ¶ added in v0.2.3
func (Null[T]) ValueOrZero ¶ added in v0.4.5
func (n Null[T]) ValueOrZero() T
ValueOrZero returns the inner value if valid, otherwise zero.
type NullDecimal ¶ added in v0.4.7
type NullDecimal = decimal.NullDecimal
type RawJSON ¶ added in v0.1.3
type RawJSON []byte
RawJSON same functionality with json.RawMessage and scan and value methods.
func (RawJSON) MarshalJSON ¶ added in v0.1.3
MarshalJSON returns m as the JSON encoding of m.
func (*RawJSON) UnmarshalJSON ¶ added in v0.1.3
UnmarshalJSON sets *m to a copy of data.