removeVexFields
removeVexFields(
props):Record<string,unknown>
Defined in: packages/core/src/versions/removeVexFields.ts:39
Strips every key a vex_versions snapshot must never carry from a stored
document before it is written into a version’s snapshot field.
Removes _id and _creationTime (Convex system fields — meaningless once
copied into an immutable history row; restoring a version never restores
an _id) and every member of VERSION_SYSTEM_FIELDS (vex_status,
vex_publishedAt, vex_publishedId — these describe the LIVE row’s
current publish state, not the content being snapshotted; re-publishing
an old snapshot must not resurrect its stale status).
Parameters
Section titled “Parameters”Input props.
Record<string, unknown>
The stored document (draft or published row) to derive a snapshot from.
fields?
Section titled “fields?”Record<string, AdminField>
The resource’s resolved field map, when known. When
given, every commitTs-typed field is stripped by TYPE (not by a fixed
key set — a collection may declare any number of commitTs fields
under any name). A raw unresolved placeholder embedded in a snapshot’s
v.any() value would, per Convex’s own docs, resolve to the SNAPSHOT
ROW’s own insert commit — meaningless, and different every time the
snapshot is rewritten — so it must never be written there at all.
Returns
Section titled “Returns”Record<string, unknown>
A new object containing only the document’s user-defined fields.
props.doc is never mutated. A doc missing some of the stripped keys (a
never-published draft has no vex_publishedId yet) is not an error —
filtering an absent key is a no-op.
Example
Section titled “Example”extractUserFields({ doc: { _id: "abc", _creationTime: 1, title: "Hi", vex_status: "draft" },});// → { title: "Hi" }