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?
optionalbatchSize?:number
Batch size for writes (default: 5000).
columnMap?
optionalcolumnMap?:Record<string,string>
Map CSV column headers to field names (e.g. { "Product Name": "name" }).
csv?
optionalcsv?:string
CSV string to parse. Provide either csv or data.
data?
optionaldata?:Record<string,string>[]
Pre-parsed rows (array of objects). Provide either csv or data.
delimiter?
optionaldelimiter?:string
CSV delimiter (default: ",".)
idColumn?
optionalidColumn?:string
CSV column to use as the record ID.
idGenerator?
optionalidGenerator?: (row,index) =>string
Function to generate IDs for each row.
Parameters
row
Record<string, any>
index
number
Returns
string
model?
optionalmodel?:ModelIdentifier
Model identifier — a BaseModel subclass or plain string name.
modelName?
optionalmodelName?:string
Model name as a plain string (alternative to model).
onBatchError?
optionalonBatchError?: (error,batchIndex) =>boolean|void
Called when a batch fails. Return false to abort.
Parameters
error
Error
batchIndex
number
Returns
boolean | void
onProgress?
optionalonProgress?: (progress) =>void
Progress callback fired after each batch.
Parameters
progress
Returns
void
operationName?
optionaloperationName?:string
Name of the registered save operation to use for import (default: "save"). The operation must accept params: { modelName, id, data }.
syncIndexes?
optionalsyncIndexes?: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?
optionaltransform?: (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?
optionaltypes?:Record<string,"string"|"number"|"boolean">
Explicit type coercion map (field name → target type).