Class Bulk<S>

Class for Bulk API

Type Parameters

Constructors

Properties

_logger: Logger
pollInterval: number = 1000

Polling interval in milliseconds

Default: 1000 (1 second)

pollTimeout: number = 30000

Polling timeout in milliseconds

Default: 30000 (30 seconds)

Methods

  • Create and start bulkload job and batch

    This method will return a Batch instance (writable stream) which you can write records into as a CSV string.

    Batch also implements the a promise interface so you can await this method to get the job results.

    Type Parameters

    Parameters

    • type: string
    • operation: Opr
    • Optional input: string | Readable | Record[]

    Returns Batch<S, Opr>

    Example

    // Insert an array of records and get the job results

    const res = await connection.bulk.load('Account', 'insert', accounts)

    Example

    // Insert records from a csv file using the returned batch stream

    const csvFile = fs.createReadStream('accounts.csv')

    const batch = conn.bulk.load('Account', 'insert')

    // The `response` event is emitted when the job results are retrieved
    batch.on('response', res => {
    console.log(res)
    })

    csvFile.pipe(batch.stream())
  • Type Parameters

    Parameters

    • type: string
    • operation: Opr
    • Optional optionsOrInput: string | Readable | Record[] | BulkOptions
    • Optional input: string | Readable | Record[]

    Returns Batch<S, Opr>