postgleam/value

Types

A PostgreSQL value

pub type Value {
  Null
  Boolean(Bool)
  Integer(Int)
  Float(Float)
  PosInfinity
  NegInfinity
  NaN
  Text(String)
  Bytea(BitArray)
  Uuid(BitArray)
  Oid(Int)
  Void
  Array(List(option.Option(Value)))
  Date(Int)
  Time(Int)
  TimeTz(microseconds: Int, tz_offset: Int)
  Timestamp(Int)
  Timestamptz(Int)
  Interval(microseconds: Int, days: Int, months: Int)
  Json(String)
  Jsonb(String)
  Numeric(String)
  Point(x: Float, y: Float)
  Inet(family: Int, address: BitArray, netmask: Int)
  Macaddr(BitArray)
}

Constructors

  • Null

    NULL

  • Boolean(Bool)

    Boolean

  • Integer(Int)

    Integer (int2, int4, int8)

  • Float(Float)

    Float (float4, float8) - normal finite values

  • PosInfinity

    Positive infinity (float4, float8, timestamp, timestamptz)

  • NegInfinity

    Negative infinity (float4, float8, timestamp, timestamptz)

  • NaN

    NaN (float4, float8, numeric)

  • Text(String)

    Text string (text, varchar, char, bpchar, name, citext, unknown, enum)

  • Bytea(BitArray)

    Raw bytes (bytea)

  • Uuid(BitArray)

    UUID as 16-byte binary

  • Oid(Int)

    OID (oid, regclass, regtype, xid, cid, etc.)

  • Void

    Void (void type, no data)

  • Array(List(option.Option(Value)))

    Array of values

  • Date(Int)

    Date as days since 2000-01-01 (negative for dates before)

  • Time(Int)

    Time as microseconds since midnight

  • TimeTz(microseconds: Int, tz_offset: Int)

    TimeTZ as microseconds since midnight + timezone offset in seconds

  • Timestamp(Int)

    Timestamp as microseconds since 2000-01-01 00:00:00

  • Timestamptz(Int)

    Timestamptz as microseconds since 2000-01-01 00:00:00 UTC

  • Interval(microseconds: Int, days: Int, months: Int)

    Interval: microseconds, days, months

  • Json(String)

    JSON string (already serialized)

  • Jsonb(String)

    JSONB string (already serialized)

  • Numeric(String)

    Numeric as string representation (preserving precision)

  • Point(x: Float, y: Float)

    Point (x, y)

  • Inet(family: Int, address: BitArray, netmask: Int)

    Inet/CIDR address: family (2=ipv4, 3=ipv6), address bytes, netmask

  • Macaddr(BitArray)

    MAC address (6 bytes)

Values

pub fn uuid_from_string(s: String) -> Result(Value, Nil)

Parse a UUID string into a Uuid value. Accepts formats: “550e8400-e29b-41d4-a716-446655440000” or “550e8400e29b41d4a716446655440000” (with or without dashes).

pub fn uuid_to_string(val: Value) -> Result(String, Nil)

Format a Uuid value as a hyphenated string. Returns “550e8400-e29b-41d4-a716-446655440000” format.

Search Document