Skip to content

Research: txid handshake patterns across ORM frameworks #3910

@KyleAMathews

Description

@KyleAMathews

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions