Open vitaly-t opened 8 years ago
I'm author of pg-async.
My library is lighter than @vitaly-t's pg-promise, but I think still powerfull.
I've created SQL template tag, that let you write readable SQL code that uses node-postgres argument placeholders ($1, $2, ...) but optionaly you can use transformation function or inline another SQL fragment.
Also my implementation is checking for improper use of connection methods. For example, if you try run multiple commands in parallel on same client instance, you will get error. Single client instance cannot run commands on parallel, node-postgres will serialize it anyway if someone try this so i decided throw error because author's intention was probably different. You can run queries parallel on multiple connections.
See example and/or open issue for more info
@langpavel
For example, if you try run multiple commands on same client instance, you will get error.
node-postgres does allow multiple commands to be executed as a single query, and it will provide the Result object back accordingly. I know many people are using it, concatenating queries and then getting corresponding results, or ignoring them.
Besides, to be able to execute concatenated queries is the most efficient way to optimize the server side. See Performance Boost.
Oh, @vitaly-t, sorry. I edited my post above (change is in bold).
What I mean is trying to run queries in parallel on one client. Queries are serialized on connection level. I'm right? In this case code can suggest that commands are run in paralel but this is not what really happening. Does this make sense? Actually I use one connection for multiple commands. Bulk insert support will be probably next optimalization in my library :-)
Queries are serialized on connection level. I'm right?
You are right. But let's curb the discussion, this project's issues is the wrong place for it ;)
I found within the large pool of projects based on pg-promise that when people want to use it with ES7 syntax, they just combine pg-promise with Babel, and that's it.
Some guidelines: http://stackoverflow.com/questions/33624104/how-do-i-setup-babel-6-with-node-js-to-use-es6-in-my-server-side-code