diff --git a/README.md b/README.md index 543bc309..a1045959 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/packages/drizzle-driver/README.md b/packages/drizzle-driver/README.md index 6ab6f2c2..3523df9c 100644 --- a/packages/drizzle-driver/README.md +++ b/packages/drizzle-driver/README.md @@ -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') @@ -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 diff --git a/packages/drizzle-driver/src/utils/compilableQuery.ts b/packages/drizzle-driver/src/utils/compilableQuery.ts index 6520c71f..badb6345 100644 --- a/packages/drizzle-driver/src/utils/compilableQuery.ts +++ b/packages/drizzle-driver/src/utils/compilableQuery.ts @@ -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 ( + * + * {listRecords.map((l) => ( + * {JSON.stringify(l)} + * ))} + * + * ); + */ export function toCompilableQuery(query: { execute: () => Promise; toSQL: () => Query;