Skip to content

serializeMessage

serializeMessage<Desc>(schema, message, columnMap?, columns?, operation?, contextValues?): Record<string, unknown>

Defined in: packages/repo/src/serialization.ts:111

Convert a protobuf message into a plain object suitable for database insertion. Uses @bufbuild/protobuf’s toJson for type-safe serialization (bigints as strings, Timestamps as RFC 3339, etc.), then remaps keys via the optional columnMap.

When a columns config is provided:

  • Fields with ignore: true are excluded from the output.
  • Fields with serialize are transformed before being written.
  • Fields with name overrides use the specified database column name.

Desc extends DescMessage

Desc

The message descriptor.

MessageShape<Desc>

The message to serialize.

Record<string, string>

Map of proto field names (snake_case) to database column names.

Partial<{ [K in string]: ColumnConfig<Desc, K, unknown> }>

Per-field column configuration.

ColumnSerializeOperation = "create"

ContextValues = ...

Record<string, unknown>