diff --git a/src/content/docs/d1/best-practices/local-development.mdx b/src/content/docs/d1/best-practices/local-development.mdx index 948ecee5bfe31c5..3668e4355af4651 100644 --- a/src/content/docs/d1/best-practices/local-development.mdx +++ b/src/content/docs/d1/best-practices/local-development.mdx @@ -151,7 +151,7 @@ You can then use the `getD1Database()` method to retrieve the simulated database const db = await mf.getD1Database("DB"); const stmt = db.prepare("SELECT name, age FROM users LIMIT 3"); -const { results } = await stmt.all(); +const { results } = await stmt.run(); console.log(results); ``` diff --git a/src/content/docs/d1/best-practices/remote-development.mdx b/src/content/docs/d1/best-practices/remote-development.mdx index 95abccf312bf727..5794bb2eeeea9b5 100644 --- a/src/content/docs/d1/best-practices/remote-development.mdx +++ b/src/content/docs/d1/best-practices/remote-development.mdx @@ -39,7 +39,7 @@ Use the following Worker script to verify that the Worker has access to the boun ```js export default { async fetch(request, env, ctx) { - const res = await env.DB.prepare("SELECT 1;").all(); + const res = await env.DB.prepare("SELECT 1;").run(); return new Response(JSON.stringify(res, null, 2)); }, }; diff --git a/src/content/docs/d1/examples/d1-and-hono.mdx b/src/content/docs/d1/examples/d1-and-hono.mdx index 0552626134e1460..9050851aa5c1e00 100644 --- a/src/content/docs/d1/examples/d1-and-hono.mdx +++ b/src/content/docs/d1/examples/d1-and-hono.mdx @@ -48,7 +48,7 @@ app.get("/query/users/:id", async (c) => { "SELECT * FROM users WHERE user_id = ?", ) .bind(userId) - .all(); + .run(); return c.json(results); } catch (e) { return c.json({ err: e.message }, 500); @@ -76,7 +76,7 @@ app.get("/query/users/:id", async (c) => { "SELECT * FROM users WHERE user_id = ?", ) .bind(userId) - .all(); + .run(); return c.json(results); } catch (e) { return c.json({ err: e.message }, 500); diff --git a/src/content/docs/d1/examples/d1-and-remix.mdx b/src/content/docs/d1/examples/d1-and-remix.mdx index f61b7bb83ad2a0f..55d681fc11833f0 100644 --- a/src/content/docs/d1/examples/d1-and-remix.mdx +++ b/src/content/docs/d1/examples/d1-and-remix.mdx @@ -39,7 +39,7 @@ interface Env { export const loader: LoaderFunction = async ({ context, params }) => { let env = context.cloudflare.env as Env; - let { results } = await env.DB.prepare("SELECT * FROM users LIMIT 5").all(); + let { results } = await env.DB.prepare("SELECT * FROM users LIMIT 5").run(); return json(results); }; diff --git a/src/content/docs/d1/examples/query-d1-from-python-workers.mdx b/src/content/docs/d1/examples/query-d1-from-python-workers.mdx index 18a7b826c6108d1..b77c2a6fda0ef4b 100644 --- a/src/content/docs/d1/examples/query-d1-from-python-workers.mdx +++ b/src/content/docs/d1/examples/query-d1-from-python-workers.mdx @@ -87,7 +87,7 @@ async def on_fetch(request, env): # Do anything else you'd like on request here! # Query D1 - we'll list all tables in our database in this example - results = await env.DB.prepare("PRAGMA table_list").all() + results = await env.DB.prepare("PRAGMA table_list").run() # Return a JSON response return Response.json(results) diff --git a/src/content/docs/d1/get-started.mdx b/src/content/docs/d1/get-started.mdx index 7745d71d8e5a563..b4fdabfe531315e 100644 --- a/src/content/docs/d1/get-started.mdx +++ b/src/content/docs/d1/get-started.mdx @@ -342,7 +342,7 @@ After you have set up your database, run an SQL query from within your Worker. "SELECT * FROM Customers WHERE CompanyName = ?", ) .bind("Bs Beverages") - .all(); + .run(); return Response.json(results); } @@ -387,7 +387,7 @@ You can query your D1 database using your Worker. "SELECT * FROM Customers WHERE CompanyName = ?" ) .bind("Bs Beverages") - .all(); + .run(); return new Response(JSON.stringify(results), { headers: { 'Content-Type': 'application/json' } }); diff --git a/src/content/docs/d1/sql-api/sql-statements.mdx b/src/content/docs/d1/sql-api/sql-statements.mdx index 88b8023c2c9b388..112ff4ebc4e9e4e 100644 --- a/src/content/docs/d1/sql-api/sql-statements.mdx +++ b/src/content/docs/d1/sql-api/sql-statements.mdx @@ -64,7 +64,7 @@ const { results } = await env.DB.prepare( "SELECT * FROM Customers WHERE CompanyName LIKE ?", ) .bind("%eve%") - .all(); + .run(); console.log("results: ", results); ``` ```js output diff --git a/src/content/docs/d1/tutorials/build-a-comments-api/index.mdx b/src/content/docs/d1/tutorials/build-a-comments-api/index.mdx index 1466e870fb13aa2..c983c19bd89e929 100644 --- a/src/content/docs/d1/tutorials/build-a-comments-api/index.mdx +++ b/src/content/docs/d1/tutorials/build-a-comments-api/index.mdx @@ -155,12 +155,12 @@ app.get("/api/posts/:slug/comments", async (c) => { `, ) .bind(slug) - .all(); + .run(); return c.json(results); }); ``` -The above code makes use of the `prepare`, `bind`, and `all` functions on a D1 binding to prepare and execute a SQL statement. Refer to [D1 Workers Binding API](/d1/worker-api/) for a list of all methods available. +The above code makes use of the `prepare`, `bind`, and `run` functions on a D1 binding to prepare and execute a SQL statement. Refer to [D1 Workers Binding API](/d1/worker-api/) for a list of all methods available. In this function, you accept a `slug` URL query parameter and set up a new SQL statement where you select all comments with a matching `post_slug` value to your query parameter. You can then return it as a JSON response. diff --git a/src/content/docs/d1/tutorials/build-a-staff-directory-app/index.mdx b/src/content/docs/d1/tutorials/build-a-staff-directory-app/index.mdx index 8cb945981caa4f5..572ad7682e2bec2 100644 --- a/src/content/docs/d1/tutorials/build-a-staff-directory-app/index.mdx +++ b/src/content/docs/d1/tutorials/build-a-staff-directory-app/index.mdx @@ -185,7 +185,7 @@ export const findAllEmployees = async (db: D1Database) => { JOIN locations ON employees.location_id = locations.location_id JOIN departments ON employees.department_id = departments.department_id `; - const { results } = await db.prepare(query).all(); + const { results } = await db.prepare(query).run(); const employees = results; return employees; }; diff --git a/src/content/docs/d1/tutorials/using-read-replication-for-e-com/index.mdx b/src/content/docs/d1/tutorials/using-read-replication-for-e-com/index.mdx index 5145cad12f40c07..1e091895b9062a0 100644 --- a/src/content/docs/d1/tutorials/using-read-replication-for-e-com/index.mdx +++ b/src/content/docs/d1/tutorials/using-read-replication-for-e-com/index.mdx @@ -748,7 +748,7 @@ app.get("/api/products", async (c) => { try { return await withRetry(async () => { - const { results } = await session.prepare("SELECT * FROM products").all(); + const { results } = await session.prepare("SELECT * FROM products").run(); const latestBookmark = session.getBookmark(); diff --git a/src/content/docs/d1/worker-api/index.mdx b/src/content/docs/d1/worker-api/index.mdx index 586f92c67e2cdac..7630f0108a92b90 100644 --- a/src/content/docs/d1/worker-api/index.mdx +++ b/src/content/docs/d1/worker-api/index.mdx @@ -101,7 +101,7 @@ export default { const { pathname } = new URL(request.url); // if (pathname === "/api/beverages") { // // If you did not use `DB` as your binding name, change it here - // const { results } = await env.DB.prepare("SELECT * FROM Customers WHERE CompanyName = ?",).bind("Bs Beverages").all(); + // const { results } = await env.DB.prepare("SELECT * FROM Customers WHERE CompanyName = ?",).bind("Bs Beverages").run(); // return Response.json(results); // } const companyName1 = `Bs Beverages`; diff --git a/src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx b/src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx index c07f752481d08b4..bcdc6a1fce25056 100644 --- a/src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx +++ b/src/content/docs/pages/framework-guides/deploy-a-remix-site.mdx @@ -163,7 +163,7 @@ export const loader: LoaderFunction = async ({ context, params }) => { const { env, cf, ctx } = context.cloudflare; let { results } = await env.DB.prepare( "SELECT * FROM products where id = ?1" - ).bind(params.productId).all(); + ).bind(params.productId).run(); return json(results); }; diff --git a/src/content/docs/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai.mdx b/src/content/docs/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai.mdx index cbeb8011366102d..bf3592857fad199 100644 --- a/src/content/docs/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai.mdx +++ b/src/content/docs/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai.mdx @@ -370,7 +370,7 @@ app.get("/", async (c) => { let notes = []; if (vecId) { const query = `SELECT * FROM notes WHERE id = ?`; - const { results } = await c.env.DB.prepare(query).bind(vecId).all(); + const { results } = await c.env.DB.prepare(query).bind(vecId).run(); if (results) notes = results.map((vec) => vec.text); } diff --git a/src/content/docs/workers/languages/python/examples.mdx b/src/content/docs/workers/languages/python/examples.mdx index a083955863c2683..e9f81c2247a3047 100644 --- a/src/content/docs/workers/languages/python/examples.mdx +++ b/src/content/docs/workers/languages/python/examples.mdx @@ -105,7 +105,7 @@ async def on_fetch(request, env): from workers import Response async def on_fetch(request, env): - results = await env.DB.prepare("PRAGMA table_list").all() + results = await env.DB.prepare("PRAGMA table_list").run() # Return a JSON response return Response.json(results) ``` diff --git a/src/content/docs/workers/runtime-apis/bindings/service-bindings/rpc.mdx b/src/content/docs/workers/runtime-apis/bindings/service-bindings/rpc.mdx index 91d116eadcfb4df..b1a3d9ceadd74b6 100644 --- a/src/content/docs/workers/runtime-apis/bindings/service-bindings/rpc.mdx +++ b/src/content/docs/workers/runtime-apis/bindings/service-bindings/rpc.mdx @@ -145,7 +145,7 @@ export class UserEntrypoint extends WorkerEntrypoint { "SELECT title FROM tasks WHERE user_id = ?" ) .bind(userId) - .all(); + .run(); } async createTask(userId, title) { diff --git a/src/content/docs/workflows/examples/send-invoices.mdx b/src/content/docs/workflows/examples/send-invoices.mdx index bbd78e1e85431ed..67b09afa6c86382 100644 --- a/src/content/docs/workflows/examples/send-invoices.mdx +++ b/src/content/docs/workflows/examples/send-invoices.mdx @@ -82,7 +82,7 @@ export class cartInvoicesWorkflow extends WorkflowEntrypoint { `SELECT * FROM cart WHERE id = ?`, ) .bind(event.payload.cartId) - .all(); + .run(); // should return { checkedOut: true, amount: 250 , account: { email: "celsomartinho@gmail.com" }}; if (results[0].checkedOut === false) { throw new Error("cart hasn't been checked out yet");