conv

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package conv holds the conversions every database backend uses at its model boundary, so the backends cannot each invent their own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CostText

func CostText(c *money.USD) *string

CostText stores an unknown cost as NULL and a known one as its exact text.

func LikePattern

func LikePattern(term string) string

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

func MetadataJSON(m map[string]string) (string, error)

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 OptionalID

func OptionalID(i id.ID) *string

OptionalID stores id.Nil as NULL.

func ParseCost

func ParseCost(s *string) (*money.USD, error)

ParseCost reads NULL as an unknown cost. It accepts exponent notation because some databases print decimals that way.

func ParseMetadata

func ParseMetadata(s string) (map[string]string, error)

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

func ParseOptional(s *string, parse func(string) (id.ID, error)) (id.ID, error)

ParseOptional reads NULL and "" as id.Nil. Rows written before attribution was nullable hold "" for "nobody".

func ParseTimeText

func ParseTimeText(s string) (time.Time, error)

ParseTimeText reads TimeText's format.

func TimeText

func TimeText(t time.Time) string

TimeText formats t in UTC for a text column that is compared and ordered.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL