vapor-community / postgresql

Robust PostgreSQL interface for Swift
MIT License
131 stars 33 forks source link

Examples don't show what to do with the result. #69

Closed ADGrant closed 6 years ago

ADGrant commented 6 years ago

E.g. call execute with a "select *" on a table to return a list of rows. How are the rows accessed.

vzsg commented 6 years ago

The execute method returns a Node (a very common type in Vapor 2), which contains an array or a null value.

For example:

let result = try conn.execute("SELECT * FROM foo f WHERE f.bar = $1", ["baz"]).array ?? []
// result is an [Node]

On how to extract values from the Nodes, you can check the tests.