-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skipping connection pools or sharing them between multiple Knex instances #56
Comments
Everything will be very decoupled in the next release - take a look here for what I'm thinking for the pool facade... If you can wait a few days till I wrap that up, that would probably be your best bet... |
That's good! I can wait. Thanks. |
Yes, it'll be possible to do that. |
Superb. Thanks! |
@moll - so 0.4.0 is out... the client and pool both have an extend method similar to Backbone's extend, and you should be able to sub-class the client to create a custom one, swapping in methods and whatnot wherever you want. I could go into more detail, but I'm guessing you can figure it out... http://knexjs.org/docs/clients/pool.html - feel free to ping me with additional questions though. |
Hey, Thanks though I still don't see a way to do what I was thinking before, so maybe you can shine some light: First, didn't really want to subclass pool, more like wanted to pass an outside pool instance into Knex as a way to share connections between the parent app and any library. This way a library wanting to making queries on behalf of the parent app need not concern the parent with Knex. Knex is a query builder, after all. From what I'm seeing, 0.4.0 has What I was more after is having Knex use an existing pool that has no knowledge of Knex, merely that it has two methods On that topic — is there a pool library that would actually take care of connecting, too? I see you're implementing |
You can now use the .connection method in 0.6 to explicitly specify a connection. |
👍 |
Hey,
I'm writing a library that would like to use Knex for its query building, but don't want to advertise that fact outside the library. I also don't want to everyone to run more than one connection pool.
How would you envision sharing connection pools between Knex and the outside world? Perhaps settle on some standard type of a pool or just a couple of functions with an agreed upon signature for getting a connection and releasing it?
Or perhaps ignore Knex's pooling at all and try to have it run the query directly on a Pg.Client instance given to it? Currently unfortunately they seem so coupled... Knex passing SQL arrays to multi query functions passing builders with SQL to client wrappers to... somethings.
Could you perhaps give an answer off the top of your head for now how to take a Knex built query and run it on the Pg.Client instance given to it, skipping all of the pooling and mooling? Thanks!
The text was updated successfully, but these errors were encountered: