Git Product home page Git Product logo

b1's Introduction

Bun + D1 + Drizzle

CloudflareのREST APIとDrizzleのHTTP Proxyを用いてD1にクエリする。 とても遅い。

To install dependencies:

bun install

To run:

bun run app/main.ts

This project was created using bun init in bun v1.1.12. Bun is a fast all-in-one JavaScript runtime.

準備

  • ファイル「wrangler.toml」の「database_id」を変更する
  • ファイル「.env.local」を追加する

.env

環境変数を書き込む。

CLOUDFLARE_API_TOKEN=""
CLOUDFLARE_ACCOUNT_ID=""
CLOUDFLARE_DATABASE_ID=""

CLOUDFLARE_API_TOKEN

Cloudflareの右上の「My Profile」からトークンを発行する。

My Profile > API Tokens > Create Token > Create Custom Token

Permissionsに2つを追加してトークンを作成する。

Account / D1 / Edit
Account / D1 / Read

CLOUDFLARE_ACCOUNT_ID

以下のURLにアクセスしてAccount IDを取得する。

Workers > Overview > Account ID

CLOUDFLARE_DATABASE_ID

データベースの詳細ページに記載されている。

データベースを初期化する

ファイル「wrangler.toml」の「database_id」を変更してから実行する。

bunx wrangler d1 migrations apply b1 --remote

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.