kysely-libsql
kysely-libsql copied to clipboard
How to use this with the capacitor libsql plugin?
https://capawesome.io/plugins/libsql/
looking at their usage, first few lines:
import { Libsql } from '@capawesome/capacitor-libsql';
const connectToLocalDatabase = async () => {
const { connectionId } = await Libsql.connect({
path: 'database.db',
});
console.log('Connected to database with ID:', connectionId);
};
const connectToRemoteDatabase = async () => {
const { connectionId } = await Libsql.connect({
url: 'libsql://your-database-url.turso.io',
authToken: 'your-auth-token',
});
console.log('Connected to remote database with ID:', connectionId);
};
So the question is: How do we use this in this kysely dialect? The usage here in this package:
const db = new Kysely<Database>({
dialect: new LibsqlDialect({
url: "libsql://localhost:8080?tls=0",
authToken: "<token>", // optional
}),
});
OR
const client = createClient({
url: "libsql://localhost:8080",
});
const db = new Kysely<Database>({
dialect: new LibsqlDialect({ client }),
});
// after you are done with the `db`, you must close the `client`:
client.close();
Would really appreciate it if somebody could shed some light here.
EDIT: I think there needs to be a separate CapacitorLibsqlDialect ...