Structures

The following structures are available globally.

  • Metadata about a column in the results of executing a Statement.

    See more

    Declaration

    Swift

    public struct ColumnMetadata
  • The configuration for a Connection to the Postgres server.

    See more

    Declaration

    Swift

    public struct ConnectionConfiguration
  • The configuration of a ConnectionPool.

    See more

    Declaration

    Swift

    public struct ConnectionPoolConfiguration
  • Performance metrics for a ConnectionPool.

    See more

    Declaration

    Swift

    public struct ConnectionPoolMetrics : CustomStringConvertible
  • Describes an event to be logged.

    See more

    Declaration

    Swift

    public struct LogRecord
  • A notice received from the Postgres server.

    See more

    Declaration

    Swift

    public struct Notice : CustomStringConvertible
  • A namespace for properties and methods used throughout PostgresClientKit.

    See more

    Declaration

    Swift

    public struct Postgres
  • Represents a Postgres BYTEA value (a byte array).

    See more

    Declaration

    Swift

    public struct PostgresByteA:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • Represents a Postgres DATE value, which consists of the following components:

    • year
    • month
    • day

    For example, 2019-03-14.

    See more

    Declaration

    Swift

    public struct PostgresDate:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • Represents a Postgres TIME value, which consists of the following components:

    • hour
    • minute
    • seconds (and fractional seconds)

    For example, 16:25:19.365.

    Like Foundation DateComponents, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the Foundation DateFormatter class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.

    See more

    Declaration

    Swift

    public struct PostgresTime:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • Represents a Postgres TIME WITH TIME ZONE value, which consists of the following components:

    • hour
    • minute
    • seconds (and fractional seconds)
    • time zone (expressed as an offset from UTC/GMT)

    For example, 20:10:05.128-07:00.

    Unlike TIMESTAMP WITH TIME ZONE, a TIME WITH TIME ZONE value is not normalized to UTC/GMT; the time zone in which it is specified is preserved.

    Like Foundation DateComponents, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the Foundation DateFormatter class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.

    See more

    Declaration

    Swift

    public struct PostgresTimeWithTimeZone:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • Represents a Postgres TIMESTAMP value, which consists of the following components:

    • year
    • month
    • day
    • hour
    • minute
    • seconds (and fractional seconds)

    For example, 2019-03-14 16:25:19.365.

    Unlike TIMESTAMP WITH TIME ZONE, a TIMESTAMP value does not have a time zone component. Consequently, it does not, by itself, represent a specific moment in time. For example, if two persons in different time zones wished to schedule a telephone call, the call’s starting time could not be unambiguously recorded by a TIMESTAMP value because it would not indicate in which time zone the date and time components are to be interpreted.

    (For this reason, TIMESTAMP WITH TIME ZONE is often a more useful data type. See PostgresTimestampWithTimeZone.)

    Like Foundation DateComponents, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the Foundation DateFormatter class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.

    See more

    Declaration

    Swift

    public struct PostgresTimestamp:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • Represents a Postgres TIMESTAMP WITH TIME ZONE value, which consists of the following components:

    • year
    • month
    • day
    • hour
    • minute
    • seconds (and fractional seconds)
    • time zone (expressed as an offset from UTC/GMT)

    For example, 2019-03-14 16:25:19.365+00:00.

    Like Postgres itself, PostgresClientKit normalizes TIMESTAMP WITH TIME ZONE values by converting them to UTC/GMT. The values are thus simply moments in time and representable by Foundation Date instances.

    Like Foundation DateComponents, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the Foundation DateFormatter class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.

    See more

    Declaration

    Swift

    public struct PostgresTimestampWithTimeZone:
        PostgresValueConvertible, Equatable, Decodable, CustomStringConvertible
  • A value to be sent to or returned from the Postgres server.

    PostgresClientKit extends standard Swift types to conform to the PostgresValueConvertible protocol, making it easy to convert instances of those types to PostgresValue. For example:

    // Convert String to PostgresValue.
    let greeting = "Hello, world!"
    let greetingValue = greeting.postgresValue
    
    // Convert Double to PostgresValue.
    let pi = 3.14
    let piValue = pi.postgresValue
    
    // Convert an optional Int to PostgresValue.
    let score: Int? = nil
    let scoreValue = score.postgresValue
    

    Use PostgresValue methods to convert PostgresValue instances back to standard Swift types. These methods throw errors if the conversion fails.

    try greetingValue.string()      // "Hello, world!"
    try greetingValue.int()         // throws PostgresError.valueConversionError
    
    try piValue.double()            // 3.14
    try piValue.string()            // "3.14"
    
    try scoreValue.optionalInt()    // nil
    try scoreValue.int()            // throws PostgresError.valueIsNil
    
    See more

    Declaration

    Swift

    public struct PostgresValue : PostgresValueConvertible, Equatable, CustomStringConvertible
  • Row

    A Row exposed by a Cursor.

    See more

    Declaration

    Swift

    public struct Row : CustomStringConvertible