Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- [packages/web](./packages/web/README.md)

- JS Web SDK implementation (extension of `packages/common`)

- [packages/react](./packages/react/README.md)

- React integration for PowerSync.
Expand All @@ -38,9 +38,13 @@

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

- [packages/drizzle-driver](./packages/drizzle-driver/README.md)

- Drizzle integration (ORM) for React Native and JavaScript/TypeScript projects.

- [packages/powersync-op-sqlite](./packages/powersync-op-sqlite/README.md)

- OP-SQLite integration for React Native projects.
- OP-SQLite integration for React Native projects.

- [packages/common](./packages/common/README.md)
- Shared package: TypeScript implementation of a PowerSync database connector and streaming sync bucket implementation.
Expand Down
4 changes: 1 addition & 3 deletions packages/drizzle-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { relations } from 'drizzle-orm';
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { appSchema } from './schema';

import { wrapPowerSyncWithDrizzle } from '@powersync/drizzle-driver';

export const lists = sqliteTable('lists', {
id: text('id'),
name: text('name')
Expand Down Expand Up @@ -63,7 +61,7 @@ export const db = wrapPowerSyncWithDrizzle(powerSyncDb, {

## Known limitations

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

### Compilable queries
Expand Down
19 changes: 19 additions & 0 deletions packages/drizzle-driver/src/utils/compilableQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import { CompilableQuery } from '@powersync/common';
import { Query } from 'drizzle-orm';

/**
* Converts a Drizzle query into a `CompilableQuery` compatible with PowerSync hooks.
* It allows you to seamlessly integrate Drizzle queries with PowerSync for
* reactive data fetching and real-time updates.
*
* @example
* import { toCompilableQuery } from '@powersync/drizzle-driver';
*
* const query = db.select().from(lists);
* const { data: listRecords, isLoading } = useQuery(toCompilableQuery(query));
*
* return (
* <View>
* {listRecords.map((l) => (
* <Text key={l.id}>{JSON.stringify(l)}</Text>
* ))}
* </View>
* );
*/
export function toCompilableQuery<T>(query: {
execute: () => Promise<T | T[]>;
toSQL: () => Query;
Expand Down
Loading