serializeMessage
serializeMessage<
Desc>(schema,message,columnMap?,columns?):Record<string,unknown>
Defined in: serialization.ts:60
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: trueare excluded from the output. - Fields with
serialize: "json"are stored as JSON strings viatoJsonString. - Fields with
serialize: "binary"are stored asUint8ArrayviatoBinary. - Fields with
nameoverrides use the specified database column name.
Type Parameters
Section titled “Type Parameters”Desc extends DescMessage
Parameters
Section titled “Parameters”schema
Section titled “schema”Desc
The message descriptor.
message
Section titled “message”MessageShape<Desc>
The message to serialize.
columnMap?
Section titled “columnMap?”Record<string, string>
Map of proto field names (snake_case) to database column names.
columns?
Section titled “columns?”Record<string, ColumnConfig>
Per-field column configuration.
Returns
Section titled “Returns”Record<string, unknown>