@d1testflare/d1
v2.9.0
Published
Workers D1 module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers
Downloads
77
Maintainers
Readme
@d1testflare/d1
Workers D1 module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers. See 📦 D1 for more details.
Example
import { BetaDatabase } from "@d1testflare/d1";
import { createSQLiteDB } from "@d1testflare/shared";
const db = new BetaDatabase(await createSQLiteDB(":memory:"));
await db.exec(
`CREATE TABLE my_table (cid INTEGER PRIMARY KEY, name TEXT NOT NULL);`
);
const response = await db.prepare(`SELECT * FROM sqlite_schema`).all();
console.log(await response);
/*
{
"success": true,
"results": [
{
"type": "table",
"name": "my_table",
"tbl_name": "my_table",
"rootpage": 2,
"sql": "CREATE TABLE my_table (cid INTEGER PRIMARY KEY, name TEXT NOT NULL)"
}
],
...
}
*/