Created
September 3, 2023 06:16
-
-
Save shuymn/0b46da1cf8aed79be197d7f46fff37cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Miniflare } from 'miniflare' | |
const mf = new Miniflare({ | |
modules: true, | |
script: 'addEventListener("fetch", (event) => event.respondWith(new Response(null, { status: 404 })));', | |
d1Databases: ['DEBUG'], | |
}) | |
const QUERY = ` | |
CREATE TABLE debug ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
name TEXT NOT NULL GENERATED ALWAYS AS (JSON_EXTRACT("properties", "$.name")) STORED, | |
properties TEXT NOT NULL | |
); | |
` | |
const db = await mf.getD1Database('DEBUG') | |
await db.prepare(QUERY).run() | |
// console.log(await db.prepare('SELECT * FROM sqlite_master').all()) | |
await mf.dispose() |
Author
shuymn
commented
Sep 3, 2023
"miniflare": "3.20230821.0",
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment