generateCopyData
generateCopyData(
rows,columns,columnTypes?):string
Defined in: packages/client/src/sync/copy.ts:234
Serialize a list of row objects into the body of a COPY ... FROM request in
TEXT format. Columns are emitted in the given order, fields are tab
separated, and rows are newline separated.
columnTypes optionally maps a column name to its Postgres udt_name; pass
it so json/jsonb columns serialize correctly.
PUBLIC (re-exported from the package root) for an app-owned, pgxsinkit-unmanaged table. Two contracts bind the caller:
columnsIS the column list of the COPY statement. The fields are emitted in exactly this order, so the same array must be named — in the same order — in theCOPY <table> (...)that ingests the bytes. buildCopyFromBlobStatement renders both from one array so they cannot drift.columnTypeskeys are DB column names, values are Postgresudt_names (text,int4,jsonb,timestamptz,_textfortext[], …). Only the json ones (json/jsonb/_json/_jsonb) change behaviour — everything else dispatches on the value’s runtime type — but passing the full map is harmless. Ajson/jsonbvalue MUST be the parsed value, per serializeCopyValue.
Parameters
Section titled “Parameters”readonly Record<string, unknown>[]
columns
Section titled “columns”readonly string[]
columnTypes?
Section titled “columnTypes?”Readonly<Record<string, string | undefined>>
Returns
Section titled “Returns”string