Skip to content

kiddyuchina/knex-cloudflare-d1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

knex-cloudflare-d1

Version

Cloudflare D1 dialect for Knex.js.

Install

npm i knex-cloudflare-d1
// Or
pnpm add knex-cloudflare-d1

Usage

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,
    });

    // ...
  }
}

Author

Kidd Yu https://github.com/kiddyuchina

License

MIT