File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
client-sdk-references/javascript-web/javascript-orm Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -175,9 +175,21 @@ Below are examples comparing Drizzle and PowerSync syntax for common database op
175175 powerSyncDb .watch (compiledQuery .sql , compiledQuery .parameters , {
176176 onResult (results ) {
177177 console .log (results .rows ? ._array );
178+ },
179+ });
180+
181+ // [{ id: '1', name: 'John' }]
182+ ` ` `
178183
179- // With Typescript typing
180- // console.log((results.rows?._array as (typeof users.$inferSelect)[]));
184+ ` ` ` ts Drizzle (TS )
185+ import { toCompilableQuery } from " @powersync/drizzle-driver" ;
186+
187+ // `compile()` is automatically called internally in the hooks, but not for `watch()`
188+ const compiledQuery = toCompilableQuery (db .select ().from (users)).compile ();
189+
190+ powerSyncDb .watch (compiledQuery .sql , compiledQuery .parameters as [], {
191+ onResult (results ) {
192+ console .log ((results .rows ? ._array as (typeof users .$inferSelect )[]));
181193 },
182194 });
183195
You can’t perform that action at this time.
0 commit comments