Skip to content

Commit 1df77aa

Browse files
mmkalthreepointone
andauthored
store-and-sync-state: use this.sql synchronously (#25396)
* store-and-sync-state: use this.sql synchronously * Update src/content/docs/agents/api-reference/store-and-sync-state.mdx * Update src/content/docs/agents/api-reference/store-and-sync-state.mdx --------- Co-authored-by: Sunil Pai <[email protected]>
1 parent 0222acd commit 1df77aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/docs/agents/api-reference/store-and-sync-state.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class MyAgent extends Agent<Env> {
189189

190190
// 'users' is just an example here: you can create arbitrary tables and define your own schemas
191191
// within each Agent's database using SQL (SQLite syntax).
192-
let user = await this.sql`SELECT * FROM users WHERE id = ${userId}`
192+
let [user] = this.sql`SELECT * FROM users WHERE id = ${userId}`
193193
return Response.json(user)
194194
}
195195
}
@@ -211,7 +211,7 @@ export class MyAgent extends Agent<Env> {
211211
let userId = new URL(request.url).searchParams.get('userId');
212212
// Supply the type parameter to the query when calling this.sql
213213
// This assumes the results returns one or more User rows with "id", "name", and "email" columns
214-
const user = await this.sql<User>`SELECT * FROM users WHERE id = ${userId}`;
214+
const [user] = this.sql<User>`SELECT * FROM users WHERE id = ${userId}`;
215215
return Response.json(user)
216216
}
217217
}
@@ -242,7 +242,7 @@ export class ReasoningAgent extends Agent<Env> {
242242
async callReasoningModel(prompt: Prompt) {
243243
let result = this.sql<History>`SELECT * FROM history WHERE user = ${prompt.userId} ORDER BY timestamp DESC LIMIT 1000`;
244244
let context = [];
245-
for await (const row of result) {
245+
for (const row of result) {
246246
context.push(row.entry);
247247
}
248248

0 commit comments

Comments
 (0)