diff --git a/client-sdk-references/javascript-web/javascript-orm/drizzle.mdx b/client-sdk-references/javascript-web/javascript-orm/drizzle.mdx index 2daf806b..3898d000 100644 --- a/client-sdk-references/javascript-web/javascript-orm/drizzle.mdx +++ b/client-sdk-references/javascript-web/javascript-orm/drizzle.mdx @@ -165,31 +165,16 @@ Below are examples comparing Drizzle and PowerSync syntax for common database op ### Watched Queries +For watched queries with Drizzle it's recommended to use the `watch()` function from the Drizzle integration which takes in a Drizzle query. + ```js Drizzle - import { toCompilableQuery } from "@powersync/drizzle-driver"; - - // `compile()` is automatically called internally in the hooks, but not for `watch()` - const compiledQuery = toCompilableQuery(db.select().from(users)).compile(); - - powerSyncDb.watch(compiledQuery.sql, compiledQuery.parameters, { - onResult(results) { - console.log(results.rows?._array); - }, - }); - - // [{ id: '1', name: 'John' }] - ``` - - ```ts Drizzle (TS) - import { toCompilableQuery } from "@powersync/drizzle-driver"; - // `compile()` is automatically called internally in the hooks, but not for `watch()` - const compiledQuery = toCompilableQuery(db.select().from(users)).compile(); + const query = db.select().from(users); - powerSyncDb.watch(compiledQuery.sql, compiledQuery.parameters as [], { + db.watch(query, { onResult(results) { - console.log((results.rows?._array as (typeof users.$inferSelect)[])); + console.log(results); }, });