DEV Community

Discussion on: Routing queries to read-only PostgreSQL replica in Node.js

Collapse
 
gajus profile image
Gajus Kuizinas

Slonik only allows you to execute one query at a time, so you cannot combine SELECT and UPDATE into one. In the context of the chosen stack, all you need to make a sane decision are the 3 criteria outlined in the post.

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Yes, then it's not for me, unfortunately. All my REST API does UPDATE/INSERT then SELECT to return the most current version of the record to pick up database-inserted data like timestamps. I would need a different mechanism. Still, it is interesting for sure. Thanks for sharing.

Thread Thread
 
jhelberg profile image
Joost Helberg

You can use the 'returning' keyword to make update and insert return the filled in columns. You don't need a select for that.