Skip to content

js-bao-wss-client


js-bao-wss-client / CsvImportOptions

Interface: CsvImportOptions<T> ​

Options for databases.importCsv(). Provide the source rows as either a raw csv string or pre-parsed data, and identify the target model via model or modelName. T types the records produced by the optional transform function.

Type Parameters ​

T ​

T extends object = Record<string, unknown>

Properties ​

batchSize? ​

optional batchSize?: number

Batch size for writes (default: 5000).


columnMap? ​

optional columnMap?: Record<string, string>

Map CSV column headers to field names (e.g. { "Product Name": "name" }).


csv? ​

optional csv?: string

CSV string to parse. Provide either csv or data.


data? ​

optional data?: Record<string, string>[]

Pre-parsed rows (array of objects). Provide either csv or data.


delimiter? ​

optional delimiter?: string

CSV delimiter (default: ",".)


idColumn? ​

optional idColumn?: string

CSV column to use as the record ID.


idGenerator? ​

optional idGenerator?: (row, index) => string

Function to generate IDs for each row.

Parameters ​

row ​

Record<string, any>

index ​

number

Returns ​

string


model? ​

optional model?: ModelIdentifier

Model identifier — a BaseModel subclass or plain string name.


modelName? ​

optional modelName?: string

Model name as a plain string (alternative to model).


onBatchError? ​

optional onBatchError?: (error, batchIndex) => boolean | void

Called when a batch fails. Return false to abort.

Parameters ​

error ​

Error

batchIndex ​

number

Returns ​

boolean | void


onProgress? ​

optional onProgress?: (progress) => void

Progress callback fired after each batch.

Parameters ​

progress ​

CsvImportProgress

Returns ​

void


operationName? ​

optional operationName?: string

Name of the registered save operation to use for import (default: "save"). The operation must accept params: { modelName, id, data }.


syncIndexes? ​

optional syncIndexes?: boolean

Sync indexes from the model schema after all data is written. Only applies when model is a BaseModel class (not a string). Defaults to true — set to false to skip post-import indexing.


transform? ​

optional transform?: (row, index) => T | null

Transform function called per row. Return null to skip a row.

T types the produced record. The input row stays Record<string, any> — the raw parsed/mapped row, whose cells originate as CSV strings — because T describes the transform's output shape, not its input.

Parameters ​

row ​

Record<string, any>

index ​

number

Returns ​

T | null


types? ​

optional types?: Record<string, "string" | "number" | "boolean">

Explicit type coercion map (field name → target type).

Documentation validated against js-bao-wss-client 3.4.0 · js-bao 0.11.0 · primitive-admin 1.0.62 · primitive-app 3.1.0 — 2026-09-30