Skip to content

๐Ÿ’พ D1

Databases

Specify D1 Databases to add to your environment as follows:

const mf = new Miniflare({
d1Databases:{
DB:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
});

Working with D1 Databases

For testing, it can be useful to put/get data from D1 storage bound to a Worker. You can do this with the getD1Database method:

const db = await mf.getD1Database("DB");
const stmt = await db.prepare("<Query>");
const returnValue = await stmt.run();
return Response.json(returnValue.results);