Skip to content

Commit b3882ac

Browse files
committed
Update readme for slightly improved flow
1 parent 2cfd592 commit b3882ac

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

packages/drizzle-driver/README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,24 @@ export const powerSyncDb = new PowerSyncDatabase({
5454
schema: appSchema
5555
});
5656

57+
// This is the DB you will use in queries
5758
export const db = wrapPowerSyncWithDrizzle(powerSyncDb, {
5859
schema: drizzleSchema
5960
});
61+
62+
// Generate the local PowerSync schema from the Drizzle schema with `toPowerSyncSchema`
63+
// Optional, but recommended, since you will only need to maintain one schema on the client-side
64+
// Read on to learn more.
65+
export const AppSchema = toPowerSyncSchema(drizzleSchema);
6066
```
6167

6268
## Schema Conversion
6369

64-
The `toPowerSyncSchema` schema function simplifies the process of integrating Drizzle with PowerSync. Define your Drizzle tables and supply the schema to the `toPowerSyncSchema` function for a unified development experience.
70+
The `toPowerSyncSchema` function simplifies the process of integrating Drizzle with PowerSync. It infers the local [PowerSync schema](https://docs.powersync.com/installation/client-side-setup/define-your-schema) from your Drizzle schema definition, providing a unified development experience.
71+
72+
As the PowerSync schema only supports SQLite types (`text`, `integer`, and `real`), the same limitation extends to the Drizzle table definitions.
6573

66-
As the PowerSync table only supports `text`, `integer`, and `real`, the same limitation extends to the Drizzle table definitions.
74+
To use it, define your Drizzle tables and supply the schema to the `toPowerSyncSchema` function:
6775

6876
```js
6977
import { toPowerSyncSchema } from '@powersync/drizzle-driver';
@@ -81,6 +89,7 @@ export const drizzleSchema = {
8189
lists
8290
};
8391

92+
// Infer the PowerSync schema from your Drizzle schema
8493
export const AppSchema = toPowerSyncSchema(drizzleSchema);
8594
```
8695

@@ -103,7 +112,7 @@ export const drizzleSchemaWithOptions = {
103112
export const AppSchema = toPowerSyncSchema(drizzleSchemaWithOptions);
104113
```
105114

106-
### Converting a Single Table From Drizzle to Powersync
115+
### Converting a Single Table From Drizzle to PowerSync
107116

108117
Drizzle tables can also be converted on a table-by-table basis with `toPowerSyncTable`.
109118

@@ -128,11 +137,7 @@ export const AppSchema = new Schema({
128137
});
129138
```
130139

131-
## Known limitations
132-
133-
- The integration does not currently support nested transactions (also known as `savepoints`).
134-
135-
### Compilable queries
140+
## Compilable queries
136141

137142
To use Drizzle queries in your hooks and composables, queries need to be converted using `toCompilableQuery`.
138143

@@ -144,3 +149,7 @@ const { data: listRecords, isLoading } = useQuery(toCompilableQuery(query));
144149
```
145150

146151
For more information on how to use Drizzle queries in PowerSync, see [here](https://docs.powersync.com/client-sdk-references/javascript-web/javascript-orm/drizzle#usage-examples).
152+
153+
## Known limitations
154+
155+
- The integration does not currently support nested transactions (also known as `savepoints`).

0 commit comments

Comments
 (0)