createDriver

The createDriver method creates the driver that runs Kysely's queries on the Client. Kysely calls it.

createDriver(): Driver
returnsDriver

A Kysely driver.

Example

import {create} from 'tinyjoin';
import {TinyJoinDialect} from 'tinyjoin/kysely';
import {Kysely} from 'kysely';

interface Database {
  tasks: {id: string; title: string};
}

const client = await create();
await client.exec(`
  CREATE TABLE tasks (id TEXT PRIMARY KEY, title TEXT NOT NULL)
`);
const db = new Kysely<Database>({dialect: new TinyJoinDialect({client})});

// Kysely creates the driver for its first query, and runs each query on
// the Client.
await db
  .insertInto('tasks')
  .values({id: 'a', title: 'Write docs'})
  .execute();
const {rows} = await client.query('SELECT * FROM tasks');
console.log(rows);
// -> [{id: 'a', title: 'Write docs'}]
await client.close();