Structures
The following structures are available globally.
-
The configuration for a
See moreConnection
to the Postgres server.Declaration
Swift
public struct ConnectionConfiguration
-
The configuration of a
See moreConnectionPool
.Declaration
Swift
public struct ConnectionPoolConfiguration
-
Declaration
Swift
public struct ConnectionPoolMetrics : CustomStringConvertible
-
Describes an event to be logged.
See moreDeclaration
Swift
public struct LogRecord
-
A notice received from the Postgres server.
See moreDeclaration
Swift
public struct Notice : CustomStringConvertible
-
A namespace for properties and methods used throughout PostgresClientKit.
See moreDeclaration
Swift
public struct Postgres
-
Represents a Postgres
See moreBYTEA
value (a byte array).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,
See more2019-03-14
.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
See moreDateComponents
, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the FoundationDateFormatter
class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.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
, aTIME WITH TIME ZONE
value is not normalized to UTC/GMT; the time zone in which it is specified is preserved.Like Foundation
See moreDateComponents
, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the FoundationDateFormatter
class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.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
, aTIMESTAMP
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 aTIMESTAMP
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. SeePostgresTimestampWithTimeZone
.)Like Foundation
See moreDateComponents
, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the FoundationDateFormatter
class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.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 FoundationDate
instances.Like Foundation
See moreDateComponents
, PostgresClientKit records fractional seconds in nanoseconds. However, due to a bug in the FoundationDateFormatter
class, only 3 fractional digits are preserved (millisecond resolution) in values sent to and received from the Postgres server.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 toPostgresValue
. 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 convertPostgresValue
instances back to standard Swift types. These methods throw errors if the conversion fails.
See moretry 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
Declaration
Swift
public struct PostgresValue : PostgresValueConvertible, Equatable, CustomStringConvertible