Skip to content

Commit c9e61f9

Browse files
committed
Fixing instances of D1 all() to run()
1 parent 68603e2 commit c9e61f9

File tree

16 files changed

+19
-19
lines changed

16 files changed

+19
-19
lines changed

src/content/docs/d1/best-practices/local-development.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ You can then use the `getD1Database()` method to retrieve the simulated database
151151
const db = await mf.getD1Database("DB");
152152

153153
const stmt = db.prepare("SELECT name, age FROM users LIMIT 3");
154-
const { results } = await stmt.all();
154+
const { results } = await stmt.run();
155155

156156
console.log(results);
157157
```

src/content/docs/d1/best-practices/remote-development.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Use the following Worker script to verify that the Worker has access to the boun
3939
```js
4040
export default {
4141
async fetch(request, env, ctx) {
42-
const res = await env.DB.prepare("SELECT 1;").all();
42+
const res = await env.DB.prepare("SELECT 1;").run();
4343
return new Response(JSON.stringify(res, null, 2));
4444
},
4545
};

src/content/docs/d1/examples/d1-and-hono.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ app.get("/query/users/:id", async (c) => {
4848
"SELECT * FROM users WHERE user_id = ?",
4949
)
5050
.bind(userId)
51-
.all();
51+
.run();
5252
return c.json(results);
5353
} catch (e) {
5454
return c.json({ err: e.message }, 500);
@@ -76,7 +76,7 @@ app.get("/query/users/:id", async (c) => {
7676
"SELECT * FROM users WHERE user_id = ?",
7777
)
7878
.bind(userId)
79-
.all();
79+
.run();
8080
return c.json(results);
8181
} catch (e) {
8282
return c.json({ err: e.message }, 500);

src/content/docs/d1/examples/d1-and-remix.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ interface Env {
3939
export const loader: LoaderFunction = async ({ context, params }) => {
4040
let env = context.cloudflare.env as Env;
4141

42-
let { results } = await env.DB.prepare("SELECT * FROM users LIMIT 5").all();
42+
let { results } = await env.DB.prepare("SELECT * FROM users LIMIT 5").run();
4343
return json(results);
4444
};
4545

src/content/docs/d1/examples/query-d1-from-python-workers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async def on_fetch(request, env):
8787
# Do anything else you'd like on request here!
8888

8989
# Query D1 - we'll list all tables in our database in this example
90-
results = await env.DB.prepare("PRAGMA table_list").all()
90+
results = await env.DB.prepare("PRAGMA table_list").run()
9191
# Return a JSON response
9292
return Response.json(results)
9393

src/content/docs/d1/get-started.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ After you have set up your database, run an SQL query from within your Worker.
342342
"SELECT * FROM Customers WHERE CompanyName = ?",
343343
)
344344
.bind("Bs Beverages")
345-
.all();
345+
.run();
346346
return Response.json(results);
347347
}
348348

@@ -387,7 +387,7 @@ You can query your D1 database using your Worker.
387387
"SELECT * FROM Customers WHERE CompanyName = ?"
388388
)
389389
.bind("Bs Beverages")
390-
.all();
390+
.run();
391391
return new Response(JSON.stringify(results), {
392392
headers: { 'Content-Type': 'application/json' }
393393
});

src/content/docs/d1/sql-api/sql-statements.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const { results } = await env.DB.prepare(
6464
"SELECT * FROM Customers WHERE CompanyName LIKE ?",
6565
)
6666
.bind("%eve%")
67-
.all();
67+
.run();
6868
console.log("results: ", results);
6969
```
7070
```js output

src/content/docs/d1/tutorials/build-a-comments-api/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ app.get("/api/posts/:slug/comments", async (c) => {
155155
`,
156156
)
157157
.bind(slug)
158-
.all();
158+
.run();
159159
return c.json(results);
160160
});
161161
```
162162

163-
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.
163+
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.
164164

165165
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.
166166

src/content/docs/d1/tutorials/build-a-staff-directory-app/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const findAllEmployees = async (db: D1Database) => {
185185
JOIN locations ON employees.location_id = locations.location_id
186186
JOIN departments ON employees.department_id = departments.department_id
187187
`;
188-
const { results } = await db.prepare(query).all();
188+
const { results } = await db.prepare(query).run();
189189
const employees = results;
190190
return employees;
191191
};

src/content/docs/d1/tutorials/using-read-replication-for-e-com/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ app.get("/api/products", async (c) => {
748748

749749
try {
750750
return await withRetry(async () => {
751-
const { results } = await session.prepare("SELECT * FROM products").all();
751+
const { results } = await session.prepare("SELECT * FROM products").run();
752752

753753
const latestBookmark = session.getBookmark();
754754

0 commit comments

Comments
 (0)