unjs / db0

📚 Lightweight SQL Connector
https://db0.unjs.io
MIT License
153 stars 15 forks source link

libsql connector #14

Closed pi0 closed 1 year ago

pi0 commented 1 year ago

https://github.com/libsql/libsql

Hebilicious commented 1 year ago

Assuming we solve this https://github.com/unjs/nitro/issues/1371 This is going to be an annoying export map to follow https://github.com/libsql/libsql-client-ts/blob/main/package.json

Because we need different versions for different environments ...

import { createClient } from "@libsql/client";

For environments that don't have a local filesystem, but support HTTP or WebSockets, including: Browsers CloudFlare Workers Netlify Edge Functions

import { createClient } from "@libsql/client/web";

For environments that only support HTTP, including Vercel Edge Functions:

import { createClient } from "@libsql/client/http";

For Deno:

// replace [version] with the client version
import { createClient } from "https://esm.sh/@libsql/client@[version]/web";

Easiest to solve this would be to create different presets, but that isn't magical ...

pi0 commented 1 year ago

We shall expose drivers extending a base like db0/connectors/turso-http, etc. And db0/connectors/turso with subpath conditions for each platform. Once nitro adds such conditions per platform, usage will be easier, however since it is always not possible to apply conditions, db0 would probably be best to expose each via explicit name.