Documentation ¶
Overview ¶
Package types implements some commonly used db serializable types like datetime, json, etc.
Index ¶
Constants ¶
const DefaultDateLayout = "2006-01-02 15:04:05.000Z"
DefaultDateLayout specifies the default app date strings layout.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime represents a time.Time instance in UTC that is wrapped and serialized using the app default date layout.
func NowDateTime ¶
func NowDateTime() DateTime
NowDateTime returns new DateTime instance with the current local time.
func ParseDateTime ¶
ParseDateTime creates a new DateTime from the provided value (could be cast.ToTime supported string, time.Time, etc.).
func (DateTime) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*DateTime) Scan ¶
Scan implements [sql.Scanner] interface to scan the provided value into the current DateTime instance.
func (DateTime) String ¶
String serializes the current DateTime instance into a formatted UTC date string.
The zero value is serialized to an empty string.
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type JsonArray ¶
type JsonArray []any
JsonArray defines a slice that is safe for json and db read/write.
func (JsonArray) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type JsonMap ¶
JsonMap defines a map that is safe for json and db read/write.
func (JsonMap) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type JsonRaw ¶
type JsonRaw []byte
JsonRaw defines a json value type that is safe for db read/write.
func ParseJsonRaw ¶
ParseJsonRaw creates a new JsonRaw instance from the provided value (could be JsonRaw, int, float, string, []byte, etc.).
func (JsonRaw) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*JsonRaw) Scan ¶
Scan implements [sql.Scanner] interface to scan the provided value into the current JsonRaw instance.
func (*JsonRaw) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.