Skip to content
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

Abstract away pg #555

Merged
merged 27 commits into from
Mar 27, 2024
Merged

Abstract away pg #555

merged 27 commits into from
Mar 27, 2024

Conversation

gajus
Copy link
Owner

@gajus gajus commented Mar 27, 2024

The primary goal of this refactor is to remove hard dependency on pg.

My intention is to move Slonik away from being a pg wrapper, to make it a universal client. The work in this PR abstracts all interactions with the database behind a pool and drivers (e.g. createPgDriver). This makes it very easy to implement drivers for pg-native, postgres and other drivers.

  • Drops dependency on pg.Pool
    • Implements a more efficient internal pooling mechanism.
    • For context, test execution time dropped from ~50 seconds down to ~6 seconds.
  • Renames getPoolState() to state()
  • Removes createMockPool
    • It was at best not useful, and at worst misleading. Even Slonik itself didn't use it. There are better ways to mock/spy connections. Refer to createPoolWithSpy as one of the possible ways.
    • Refactors all tests to use database connection instead of mocking.

@gajus gajus merged commit bba41af into main Mar 27, 2024
4 checks passed
Copy link
Contributor

🎉 This PR is included in version 39.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant