Skip to content

primaryKeyFromStreamKey

primaryKeyFromStreamKey(target, key): Record<string, unknown>

Defined in: packages/client/src/circuits/envelope-to-change.ts:86

Rebuild the LOCAL primary-key columns of a row from the stream key.

The key is the SERVER identity: composite keys are joined in server primary-key declaration order (escaped per component — see unescapeKeyComponent), single keys are the raw value. Under a clientProjection.localPrimaryKey narrowing the local key is a subset of the server key, so the split runs over serverPrimaryKey and only the local components are kept — the dropped ones are predicate-pinned (subscribe-time compile refuses the narrowing otherwise), so within this shape the narrowed key is still unique. A count mismatch is thrown rather than tolerated: a silently short split would produce a WHERE over only part of the key, and a delete matching more rows than it should is data loss, not a stale row.

ApplyTarget

string

Record<string, unknown>