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
typealias PostgresCodableA type that can be encoded into and decoded from a Postgres binary format.struct PostgresDataTypeData types and their raw OIDs.enum PostgresFormatThe format the postgres types are encoded in on the wire.struct PostgresNumeric
Encoding
protocol PostgresEncodableA type that can encode itself to a Postgres wire binary representation.protocol 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.protocol 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.protocol 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.protocol PostgresArrayEncodableA type of which arrays can be encoded into and decoded from a Postgres binary format.protocol PostgresRangeEncodableA type that can be encoded into a Postgres range type where it is the bound type.protocol PostgresRangeArrayEncodableA type that can be encoded into a Postgres range array type where it is the bound type.struct 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
protocol PostgresDecodableA type that can decode itself from a Postgres wire binary representation.protocol PostgresArrayDecodableA type that can be decoded into a Swift Array of its own type from a Postgres array.protocol PostgresRangeDecodableA type that can be decoded into a Swift RangeExpression type from a Postgres range where it is the bound type.protocol PostgresRangeArrayDecodableA type that can be decoded into a Swift RangeExpression array type from a Postgres range array where it is the bound type.struct 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
protocol 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).protocol 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.