Difference between jsforce bulk api options

1.5k Views Asked by At

I'm using jsforce to access salesforce using the bulk api. It has two ways of updating and deleting records. One is using the normal bulk api which means creating a job and batches:

var job = conn.bulk.createJob("Account", "delete");
var batch = job.createBatch();
var accounts = getAccountsByDate(jsforce.Date.TODAY);
batch.execute(accounts);

batch.on('response', function(rets) {
    // do things
});

The other way is to the "query" interface like this:

conn.sobject('Account')
    .find({ CreatedDate: jsforce.Date.TODAY })
    .destroy(function(err, rets) {
        // do things
    });

The second way certainly seems easier but I can't get it to update or delete more than 10,000 records at a time, which appears to be a salesforce api limit on batch size. Note that using maxFetch property from jsforce appears to have no effect in this case.

So is it safe to assume that the query style interface only creates a single batch? The jsforce documentation is not clear on this point.

1

There are 1 best solutions below

0
On BEST ANSWER

Currently the bulk.load() method in JSforce bulk api generates a job with one batch, so the limit of 10,000 per batch will be applied. It is also true when using find-and-destroy interface, which uses bulk.load() internally. To avoid this limit you can create a job by bulk.createJob() and create several batches by job.createBatch(), then dispatch the records to delete into these batches so that each records will not exceed the limit.