-
Notifications
You must be signed in to change notification settings - Fork 158
New driver considerations #381
Comments
Added a memo to help with a possible upgrade. |
@dmfay one of the recommended improvements - reuse of the pg-promise configuration for the custom promise library when using its
Note that support for This way, whenever a query request is made, you can use the same promise library as configured for pg-promise, rather than suddenly switching to ES6 Promise. |
oh, very cool! That's probably worth including in the release too. I've been trying to do something weird with proxies for the connection pools -- mixed results so far :) |
Are you talking about the use of |
I've got a |
The latest pg-promise version is 6.0.26. Within pg-promise architecture you get a new pool with each new The idea is to have a separate
Hopefully this will help you in making the decision in how to use it best ;) Also worth noting, pg-promise discourages creating more than one
So currently, if you go for scenario 3, you are expected to at least specify a different pool size. Otherwise, like, why creating it in the first place? :) i mean, it makes no sense having multiple pools of the same size going to the same database. |
@dmfay just curious, did you publish/submit your library somewhere after the 3.0 release? I've noticed a good spike in new stars ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ Mine got stale of lately, so I'm thinking of posting it somewhere 😄 |
Just Twitter, when I dropped the release. Looks like you had the same thought there! |
Must have been some twitter, it looks really in play 😄, though I suspect most people come from here: http://nodeweekly.com/issues/194 Come to think of it, how did you get it published there? Not by twitting? 😄 Or maybe because it got re-twitted here: https://twitter.com/javascriptdaily 😯 I won't tell anybody 😯 😸 |
Good question! I don't know either :) |
Version 7 of pg-promise has already been implemented within branch v7. The remaining bits and pieces are tests + documentation, tons of each. |
Sorry if this is a dumb question, but |
node-pg's promise support was cumbersome at best up until about four days ago, which would have made integrating it a hassle for no good reason. And pg-promise does more than just facilitating communication with the database: it handles query file management, named parameters, tasks, transactions, and so on and on. These are all things I could write myself -- eventually -- but Vitaly's implementation is at least as good as anything I could come up with. If I don't waste time reinventing the wheel, I can focus more on improving Massive itself. |
I did not know pg-promise did that many things on top of promisifying node-postgres. Thanks for the answer. |
@dmfay what do you think of this type of change for version 7? - vitaly-t/pg-promise#371 |
@dmfay You might like this update: https://github.com/vitaly-t/pg-promise/releases/tag/v.6.10.0 |
One feature in pg-promise that's been missing (made unavailable) in massive.js - Database Context, something that matters when more than one database needs to be supported, like think master + replicas, for example. See this question: https://stackoverflow.com/questions/46243680/rebuilding-connections-in-nodejs-pg-promise It is the second parameter into the Database constructor, the value which is then propagated through the entire interface to provide the database context. |
yeah, multiple databases = multiple instances of Massive for now. I need to get back into that proxy stuff I was trying out for juggling connection pools. |
Version 7.0.0 is out. You've got some catching up to do 😉 |
I've barely had time to think the last couple months let alone try to keep pace with you. Busy busy 😬 |
Well, now i'm myself fresh out. I just did a major rewrite of the documentation, no code changes. And since I'm starting a new job on the 16th, I'm likely to take a very long break away from GitHub. You get your time to catch up ;) |
congrats, have fun at the new place! |
@dmfay Congrats on 2000 stars! 😄 When are you planning to upgrade the |
Thanks! As far as upgrading: the pg-query-stream reversion to the classic style doesn't look like it's going to be changed anytime soon, and I don't want to bump to v5 over streams. Other option is to convert it to a modern stream in Massive, I guess, but that makes me itchy. I'll have to think about it. |
Now that you have updated to the latest version of pg-promise, time to consider how you can make your library faster and simpler by using these features:
|
@dmfay Unrelated to the subject,...but, your library can do all that - right? - What library do you use for postgres+jsonb in Node? If so, you may want to publish an answer ;) |
Thanks! :) |
yeah, I'm going to have to think about that -- inattention to semver has also been an issue :/ |
Since pg-promise is now the underlying driver, I wanted to make a quick list of useful considerations.
Monitoring Queries
As
Massive
constructor accepts the third parameter to configurepg-promise
, it means you have access to lots of useful options that can be set there. More interestingly, one can now attach pg-monitor to the object and see all the queries thatMassive
executes in a nice way.Stack Tracing
One of the most important aspects of development with promises - Long Stack Traces, necessary to be able to pinpoint any issue in the application. Without Long Stack Traces it is often impossible. Bluebird is the best library for that today, see Long Stack Traces. You can set Bluebird as the promise library of choice for the pg-promise driver, see option promiseLib.
Version 6.x
Version 6.x of pg-promise has been in active development recently, to allow use of the new pool strategies supported by node-postgres 6.x. And the current Beta 6.0.10 is already quite stable.
One of the best examples of the advantages provided by this version is that you can configure your database layer according to the design / business requirements for the access priority, like this:
This can really change things in a busy environment, setting the pool size according to the requirements for the load / priority.
The text was updated successfully, but these errors were encountered: