Skip to content

Commit 06ade3e

Browse files
authored
chore: Minor documentation improvements for introduction of Drizzle (#400)
1 parent b8e1848 commit 06ade3e

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- [packages/web](./packages/web/README.md)
1818

1919
- JS Web SDK implementation (extension of `packages/common`)
20-
20+
2121
- [packages/react](./packages/react/README.md)
2222

2323
- React integration for PowerSync.
@@ -38,9 +38,13 @@
3838

3939
- Kysely integration (ORM) for React Native and JavaScript/TypeScript projects.
4040

41+
- [packages/drizzle-driver](./packages/drizzle-driver/README.md)
42+
43+
- Drizzle integration (ORM) for React Native and JavaScript/TypeScript projects.
44+
4145
- [packages/powersync-op-sqlite](./packages/powersync-op-sqlite/README.md)
4246

43-
- OP-SQLite integration for React Native projects.
47+
- OP-SQLite integration for React Native projects.
4448

4549
- [packages/common](./packages/common/README.md)
4650
- Shared package: TypeScript implementation of a PowerSync database connector and streaming sync bucket implementation.

packages/drizzle-driver/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import { relations } from 'drizzle-orm';
1717
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
1818
import { appSchema } from './schema';
1919

20-
import { wrapPowerSyncWithDrizzle } from '@powersync/drizzle-driver';
21-
2220
export const lists = sqliteTable('lists', {
2321
id: text('id'),
2422
name: text('name')
@@ -63,7 +61,7 @@ export const db = wrapPowerSyncWithDrizzle(powerSyncDb, {
6361

6462
## Known limitations
6563

66-
- The integration does not currently support nested transations (also known as `savepoints`).
64+
- The integration does not currently support nested transactions (also known as `savepoints`).
6765
- The Drizzle schema needs to be created manually, and it should match the table definitions of your PowerSync schema.
6866

6967
### Compilable queries

packages/drizzle-driver/src/utils/compilableQuery.ts

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
import { CompilableQuery } from '@powersync/common';
22
import { Query } from 'drizzle-orm';
33

4+
/**
5+
* Converts a Drizzle query into a `CompilableQuery` compatible with PowerSync hooks.
6+
* It allows you to seamlessly integrate Drizzle queries with PowerSync for
7+
* reactive data fetching and real-time updates.
8+
*
9+
* @example
10+
* import { toCompilableQuery } from '@powersync/drizzle-driver';
11+
*
12+
* const query = db.select().from(lists);
13+
* const { data: listRecords, isLoading } = useQuery(toCompilableQuery(query));
14+
*
15+
* return (
16+
* <View>
17+
* {listRecords.map((l) => (
18+
* <Text key={l.id}>{JSON.stringify(l)}</Text>
19+
* ))}
20+
* </View>
21+
* );
22+
*/
423
export function toCompilableQuery<T>(query: {
524
execute: () => Promise<T | T[]>;
625
toSQL: () => Query;

0 commit comments

Comments
 (0)