This repo is an experiment around a potential MikroORM adapter for PowerSync. The goal is to explore whether MikroORM can be used as the entity, query, and mutation layer over a PowerSync local SQLite database, while a regular MikroORM backend persists data to PostgreSQL.
This is not intended to be a production-ready adapter yet. It is a working demo and research space for the API shape.
app/- React + Vite client demo. It uses PowerSync Web, raw tables, and the experimental MikroORM driver to query and mutate local SQLite state.backend/- Fastify + MikroORM backend with JWT auth, PostgreSQL entities, migrations, and article/comment API routes.packages/powersync-driver/- Experimental@powersync/mikro-ormpackage. This is the adapter layer being explored.powersync/- PowerSync service config, sync rules, and Docker Compose setup for local PostgreSQL source/storage services.scripts/- Root developer scripts, including the local dev orchestrator.patches/- Workspace patches used by this demo.
- Docker
- Node.js and pnpm
Use pnpm from the repo root. This workspace expects the Node version from
.nvmrc, so load nvm before running scripts in this folder.
nvm use
pnpm dev:localdev:local starts the Docker services, the backend in dev mode, and the Vite
client. Copy .env.template to .env when you want to override local ports or
database credentials.
The client-side flow is intentionally adapter-first:
- Create a PowerSync Web
DBAdapterwithWASQLiteOpenFactory. - Pass
{ database: adapter }to MikroORM. - Run MikroORM schema updates for the local raw tables.
- Create
PowerSyncDatabasewith the same adapter. - Use MikroORM query builders with PowerSync watched queries through
toCompatibleQuery().
Raw tables are not required for a PowerSync MikroORM integration, but this demo uses them so the local table definitions can live in the client-side MikroORM entities instead of being duplicated in PowerSync table declarations.
Some MikroORM transitive dependencies expect Node globals such as Buffer.
The app polyfills Buffer in app/src/library/polyfills/nodeGlobals.ts before
initializing React.