Cloudflare D1 dialect for Knex.js.
npm i knex-cloudflare-d1
// Or
pnpm add knex-cloudflare-d1
import Knex from 'knex';
import ClientD1 from 'knex-cloudflare-d1';
export interface Env {
DB: D1Database;
}
export default {
fetch: (req: Request, env: Env) => {
// ...
const knex = Knex({
client: ClientD1,
connection: {
database: env.DB
},
useNullAsDefault: true,
});
// ...
}
}
Kidd Yu https://github.com/kiddyuchina
MIT