-
Notifications
You must be signed in to change notification settings - Fork 23
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
allow passing custom connection instance to the connectors #19
Comments
Clients come as optional dependencies with each connector. Can you elaborate more what do you mean by client exactly and how we can avoid using them to implement connector? :) |
You can see an example of such an approach with the Lucia adapters (I'm familiar with it as I've recently made an unstorage adapter for Lucia). import { createDB, sql } from "db0";
import sqlite from "better-sqlite3";
import connector from "db0/connectors/better-sqlite3";
// or import { connectorSqlite3 } from "db0"
const db = createDB(connector({ driver: sqlite("test/main.db")})) |
I am fine with supporting generic drivers that accept client instances for advanced usage that would be a nice idea. But it takes away all possible zero config experience with nitro. This is how both unstorage and db0 are designed for to be simple and ship best practices with integration (similar how Nuxt itself integrated Vue..) |
You're right, it would make sense to do it like with unstorage. I would be satisfied if we accepted an optional client instance for each driver. |
PR welcome to add support for current connectors :) |
Describe the feature
Db0 scope seems to be to provide a connector for every SQL-like language out there, as well as a wrapper around popular ORM.
I think we should consider letting the user initialise the client however he see fits, and pass the client instance to the connector.
If we do provide every single client, we endup having to manage and take care of many depedencies that we do not control, and we run into the problems where someone want to use the client without db0 and has to create two of them, or we have to expose the client etc
We could document how to install and initialise the client for each connector.
Additional information
The text was updated successfully, but these errors were encountered: