MCPcopy Create free account
hub / github.com/TanStack/db / generateTxId

Function generateTxId

examples/solid/todo/src/api/server.ts:27–40  ·  view source on GitHub ↗
(tx: any)

Source from the content-addressed store, hash-verified

25
26// Generate a transaction ID
27async function generateTxId(tx: any): Promise<Txid> {
28 // The ::xid cast strips off the epoch, giving you the raw 32-bit value
29 // that matches what PostgreSQL sends in logical replication streams
30 // (and then exposed through Electric which we'll match against
31 // in the client).
32 const result = await tx`SELECT pg_current_xact_id()::xid::text as txid`
33 const txid = result[0]?.txid
34
35 if (txid === undefined) {
36 throw new Error(`Failed to get transaction ID`)
37 }
38
39 return parseInt(txid, 10)
40}
41
42// ===== TODOS API =====
43

Callers 1

server.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected