vapor / postgres-nio

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
https://api.vapor.codes/postgresnio/documentation/postgresnio/
MIT License
321 stars 73 forks source link

Postgres PREPARED STATEMENT example #507

Open duncangroenewald opened 2 weeks ago

duncangroenewald commented 2 weeks ago

The documentation doesn't appear to provide any examples of how to execute a prepared statement. The only reference I was able to find was a reference to use a struct but this seems at odds with creating prepared statements on the server and then executing them.

Is there any documentation or examples of executing a prepared statement from the client. The normal await client.query() doesn't appear to work.

MahdiBM commented 1 week ago

@duncangroenewald You don't need to create the statements manually on the server. PostgresNIO handles that over the wire protocol.

See these links to the implementation and a test, as an example of how to make a prepared-statement query using the PostgresClient. I haven't taken a proper look at the docs, so can't comment on that. We should add an example if there is no such example in the docs currently.

duncangroenewald commented 1 week ago

Thanks, I figured it out. Conceptually it is a little confusing at first so an explanation or at least a link to the test examples in the documentation would be a help.

MahdiBM commented 1 week ago

@duncangroenewald we agree that this issue is still valid then 🙂.