@miniflare/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 "@miniflare/d1";
import { MemoryStorage } from "@miniflare/storage-memory";
const db = new BetaDatabase(new MemoryStorage());
await db.fetch("/execute", {
method: 'POST',
body: JSON.stringify({
sql: `CREATE TABLE my_table (cid INTEGER PRIMARY KEY, name TEXT NOT NULL);`,
}),
});
const response = await db.fetch("/query", {
method: 'POST',
body: JSON.stringify({
sql: `SELECT * FROM sqlite_schema`,
}),
});
console.log(await response.json())