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
PostgresCodableA type that can be encoded into and decoded from a Postgres binary format.PostgresDataTypeData types and their raw OIDs.PostgresFormatThe format the postgres types are encoded in on the wire.PostgresNumeric
Encoding
PostgresEncodableA type that can encode itself to a Postgres wire binary representation.PostgresNonThrowingEncodableA type that can encode itself to a Postgres wire binary representation. It enforces that theencode(into:context:)does not throw. This allows users to createPostgresQuerys viaExpressibleByStringInterpolationwithout having to spelltry.PostgresDynamicTypeEncodableA 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.PostgresThrowingDynamicTypeEncodableA 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.PostgresArrayEncodableA type of which arrays can be encoded into and decoded from a Postgres binary format.PostgresRangeEncodableA type that can be encoded into a Postgres range type where it is the bound type.PostgresRangeArrayEncodableA type that can be encoded into a Postgres range array type where it is the bound type.PostgresEncodingContextA 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
PostgresDecodableA type that can decode itself from a Postgres wire binary representation.PostgresArrayDecodableA type that can be decoded into a Swift Array of its own type from a Postgres array.PostgresRangeDecodableA type that can be decoded into a Swift RangeExpression type from a Postgres range where it is the bound type.PostgresRangeArrayDecodableA type that can be decoded into a Swift RangeExpression array type from a Postgres range array where it is the bound type.PostgresDecodingContextA 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
PostgresJSONEncoderA protocol that mimics the FoundationJSONEncoder.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 (seePostgresNIO._defaultJSONEncoder).PostgresJSONDecoderA protocol that mimics the FoundationJSONDecoder.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 (seePostgresNIO._defaultJSONDecoder).
See Also
Advanced
- Boosting Performance with Prepared StatementsImprove performance by leveraging PostgreSQL’s prepared statements.
- Listen & Notify
PostgresNIOsupports PostgreSQL’s listen and notify API. Learn how to listen for changes and notify other listeners.