Skip to content

powersync-community/mikro-orm-poc

Repository files navigation

PowerSync MikroORM Demo

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.

Repo Structure

  • 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-orm package. 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.

Prerequisites

  • Docker
  • Node.js and pnpm

Local Development

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:local

dev: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.

Adapter Experiment

The client-side flow is intentionally adapter-first:

  1. Create a PowerSync Web DBAdapter with WASQLiteOpenFactory.
  2. Pass { database: adapter } to MikroORM.
  3. Run MikroORM schema updates for the local raw tables.
  4. Create PowerSyncDatabase with the same adapter.
  5. 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.

Browser Notes

Some MikroORM transitive dependencies expect Node globals such as Buffer. The app polyfills Buffer in app/src/library/polyfills/nodeGlobals.ts before initializing React.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages