electric-sql / electric-sql/electric

Research: txid handshake patterns across ORM frameworks

Open
#3,910 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10.4k
Forks
375
Avg merge
3d 1h
Merged PRs (30d)
18

Description

## Context

The Electric write-path contract requires calling `pg_current_xact_id()::text` within the same transaction as the write, then returning the txid to the client for optimistic state reconciliation.

Different ORM frameworks have varying levels of support for accessing raw transaction context. The `electric-drizzle` skill covers Drizzle, but developers use many other ORMs with Electric.

## Research needed

Survey how to implement the txid handshake in common ORM/API frameworks:

- **Drizzle** (already documented)
- **Prisma** — can you call raw SQL within a `$transaction`?
- **Knex** — transaction raw query support
- **TypeORM** — transaction manager + raw query
- **Sequelize** — transaction + raw query
- **MikroORM** — EntityManager raw query in transaction
- **Plain pg/postgres.js** — direct transaction

For each, document:
1. How to run `pg_current_xact_id()::text` in the same transaction as a write
2. Any gotchas or limitations
3. Code snippet

## Output

A reference file (e.g. `electric-txid-orm-reference`) that the `electric-tanstack-integration` and `electric-drizzle` skills can point to. Could also become a standalone skill if the content is substantial enough.

## Source

Identified during domain discovery skill test run (skill-domain-discovery v2.1).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.