vitaly-t / pg-promise

PostgreSQL interface for Node.js
https://vitaly-t.github.io/pg-promise
MIT License
3.47k stars 217 forks source link

Question re: WARNING: Creating a duplicate database object for the same connection #175

Closed CalebEverett closed 3 years ago

CalebEverett commented 8 years ago

Is the right way to set this up in an Express app to create a separate db module per the example and then require that in each set of routes? I've done that, but am still getting the warnings. Do I need a separate database object for each set of routes or can you recommend otherwise? Thanks,

vitaly-t commented 3 years ago
MatthewJamesBoyle commented 3 years ago

@vitaly-t hmm strange I could see that code until a few minutes ago on this discussion thread. Hence me quoting your reply above, as it was still visible. Glad its cleared up now though!

I added you as a contributor to the project, thanks! I can tidy up the readme of it and can perhaps serve as an example for others using your great library with next.js

vitaly-t commented 3 years ago

I won't have time for this today, you'll be better off just following the pattern as explained.

vitaly-t commented 3 years ago

@MatthewJamesBoyle Did you get this working in the end?

MatthewJamesBoyle commented 3 years ago

@vitaly-t no, I still get a development warning no matter what I try. I have moved to solve this problem with infrastructure instead for now.

vitaly-t commented 3 years ago

Well, you probably did something wrong again then, because when I just followed that code example I provided, for your demo app, it just worked, there was no warning anymore. It works.

MatthewJamesBoyle commented 3 years ago

Do you want to push it so I can see rather than just telling me I'm doing something wrong?

vitaly-t commented 3 years ago

I didn't have time to re-do it, so here's zipped code.

markojanicic-sas commented 2 years ago

Hello, reopening this. @MatthewJamesBoyle did you solve this? Currently having the exact same issue. Would love to see your JS take on above solution.

jcollum-nutrien commented 8 months ago

Here it is 5 months later and I'm seeing this issue in 11.5.4. Investigating, maybe we are doing something wrong in our code.