Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

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

Closed
ADGrant opened this issue Jan 7, 2018 · 1 comment
Closed

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

ADGrant opened this issue Jan 7, 2018 · 1 comment

Comments

@ADGrant
Copy link

ADGrant commented Jan 7, 2018

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

@vzsg
Copy link
Member

vzsg commented Jan 8, 2018

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.

@vzsg vzsg closed this as completed Jan 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants