Documentation
¶
Overview ¶
Package casts provides a small attribute-casting layer the ORM applies on reads and writes. Each cast maps SQL ↔ Go through a registered Cast. Built-in casts (and their aliases): json (jsonb), bool (boolean), int (integer), float (double), date, datetime.
Custom casts can be registered with Register() at init time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoolCast ¶
type BoolCast struct{}
BoolCast normalizes 0/1/"t"/"f"/"true"/"false" to bool.
type Cast ¶
Cast converts a value coming back from the DB (FromDB) and going to the DB (ToDB). Implementations should be allocation-conscious; they may be called many times per row.
type DateCast ¶
type DateCast struct{}
DateCast renders/parses values as YYYY-MM-DD.
type DateTimeCast ¶ added in v0.20.0
type DateTimeCast struct{}
DateTimeCast renders/parses values as RFC3339 timestamps.
type FloatCast ¶ added in v0.20.0
type FloatCast struct{}
FloatCast parses string/numeric into float64.
type IntCast ¶
type IntCast struct{}
IntCast parses string/numeric into int64.