Skip to content

Add query metadata

Pre-release
Pre-release
Compare
Choose a tag to compare
@tanner0101 tanner0101 released this 03 Apr 17:07
a528171
This patch was authored and released by @tanner0101.

Adds new API for accessing query metadata via conn.query (fixes #93).

conn.query("...", onMetadata: { metadata in 
    print(metadata.rows) // Int?
}) { row in 
    print(row) // PostgresRow
}.wait()

This is a breaking change since conn.query now returns PostgresQueryResult instead of [PostgresRow]. However, PostgresQueryResult conforms to Collection so most code should be unaffected.

let result = try conn.query("...").wait()
for row in result {
    print(row) // PostgresRow
}
print(result.metadata) // PostgresQueryMetadata
print(result.rows) // [PostgresRow]