-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Defining own Queryable
interface
#158
Comments
I think this is a good idea in principle — I'd actually like to drop the direct But, as you say, distinguishing between a Client and a Pool in the |
I think the safest way is to actually check for the behaviour of the interface. if ('connect' in queryable && typeof queryable.connect === 'function') {
// pool
} And perhaps have adapters as an additional layer. But this, ofc, would be a breaking change. .run(ZapatosPgDriverAdapter.fromPool(pgPool))
.run(ZapatosPgDriverAdapter.fromClient(client))
.run(ZapatosNeonDriverAdapter.fromClient(client)) |
I propose that this package defines it's own
Queryable
rather than usingpg
built-ins:zapatos/src/db/core.ts
Line 206 in 157da6a
The advantage of this could potentially open up uses with other compatible packages or even developing adapter for other packages.
If this was possible, I could implement this narrow interface on my own, for example to implement better retry logic.
As a minimum, we could even just narrow the type by using
Pick
. But ideally, it should be more tightly defined, and only define the parts that zapatos needs.Additionally, this type of queryable detection will need a rework:
zapatos/src/db/transaction.ts
Lines 54 to 57 in 157da6a
Related: #77
The text was updated successfully, but these errors were encountered: