Documentation
¶
Overview ¶
Package conv holds the conversions every database backend uses at its model boundary, so the backends cannot each invent their own.
Index ¶
- func CostText(c *money.USD) *string
- func LikePattern(term string) string
- func MetadataJSON(m map[string]string) (string, error)
- func OptionalID(i id.ID) *string
- func ParseCost(s *string) (*money.USD, error)
- func ParseMetadata(s string) (map[string]string, error)
- func ParseOptional(s *string, parse func(string) (id.ID, error)) (id.ID, error)
- func ParseTimeText(s string) (time.Time, error)
- func TimeText(t time.Time) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LikePattern ¶
LikePattern turns a search term into a LIKE / ILIKE pattern matching it anywhere, with the wildcards in the term escaped by a backslash.
func MetadataJSON ¶
MetadataJSON is usage metadata as the JSON text a backend stores. A nil map is stored as {}, never null, so every row holds an object.
func ParseCost ¶
ParseCost reads NULL as an unknown cost. It accepts exponent notation because some databases print decimals that way.
func ParseMetadata ¶
ParseMetadata reads what MetadataJSON wrote. An empty or null value, which a row from before metadata existed may hold, reads as an empty, non-nil map.
func ParseOptional ¶
ParseOptional reads NULL and "" as id.Nil. Rows written before attribution was nullable hold "" for "nobody".
func ParseTimeText ¶
ParseTimeText reads TimeText's format.
Types ¶
This section is empty.