Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions client-sdk-references/javascript-web/javascript-orm/drizzle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,21 @@ Below are examples comparing Drizzle and PowerSync syntax for common database op
powerSyncDb.watch(compiledQuery.sql, compiledQuery.parameters, {
onResult(results) {
console.log(results.rows?._array);
},
});

// [{ id: '1', name: 'John' }]
```

// With Typescript typing
// console.log((results.rows?._array as (typeof users.$inferSelect)[]));
```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();

powerSyncDb.watch(compiledQuery.sql, compiledQuery.parameters as [], {
onResult(results) {
console.log((results.rows?._array as (typeof users.$inferSelect)[]));
},
});

Expand Down