Skip to content

API Collection

PostgreSQL data types

Translate Swift data types to Postgres data types and vica versa. Learn how to write translations for your own custom Swift types.

Topics

Essentials

Encoding

  • PostgresEncodable
    A type that can encode itself to a Postgres wire binary representation.
  • PostgresNonThrowingEncodable
    A type that can encode itself to a Postgres wire binary representation. It enforces that the encode(into:context:) does not throw. This allows users to create PostgresQuerys via ExpressibleByStringInterpolation without having to spell try.
  • PostgresDynamicTypeEncodable
    A type that can encode itself to a Postgres wire binary representation. Dynamic types are types that don’t have a well-known Postgres type OID at compile time. For example, custom types created at runtime, such as enums, or extension types whose OID is not stable between databases.
  • PostgresThrowingDynamicTypeEncodable
    A type that can encode itself to a Postgres wire binary representation. Dynamic types are types that don’t have a well-known Postgres type OID at compile time. For example, custom types created at runtime, such as enums, or extension types whose OID is not stable between databases.
  • PostgresArrayEncodable
    A type of which arrays can be encoded into and decoded from a Postgres binary format.
  • PostgresRangeEncodable
    A type that can be encoded into a Postgres range type where it is the bound type.
  • PostgresRangeArrayEncodable
    A type that can be encoded into a Postgres range array type where it is the bound type.
  • PostgresEncodingContext
    A context that is passed to Swift objects that are encoded into the Postgres wire format. Used to pass further information to the encoding method.

Decoding

  • PostgresDecodable
    A type that can decode itself from a Postgres wire binary representation.
  • PostgresArrayDecodable
    A type that can be decoded into a Swift Array of its own type from a Postgres array.
  • PostgresRangeDecodable
    A type that can be decoded into a Swift RangeExpression type from a Postgres range where it is the bound type.
  • PostgresRangeArrayDecodable
    A type that can be decoded into a Swift RangeExpression array type from a Postgres range array where it is the bound type.
  • PostgresDecodingContext
    A context that is passed to Swift objects that are decoded from the Postgres wire format. Used to pass further information to the decoding method.

JSON

  • PostgresJSONEncoder
    A protocol that mimics the Foundation JSONEncoder.encode(_:) function. Conform a non-Foundation JSON encoder to this protocol if you want PostgresNIO to be able to use it when encoding JSON & JSONB values (see PostgresNIO._defaultJSONEncoder).
  • PostgresJSONDecoder
    A protocol that mimics the Foundation JSONDecoder.decode(_:from:) function. Conform a non-Foundation JSON decoder to this protocol if you want PostgresNIO to be able to use it when decoding JSON & JSONB values (see PostgresNIO._defaultJSONDecoder).

See Also

Advanced