When I'm trying to insertBulk
a lot of records using jsforce, only 10k records get inserted (single bulk job is being registered). The same happens with bulkDelete, when piping query result to destroyBulk
job.
As a workaround, I'm using the following code to chain bulk calls, but to be honest, that doesn't seem like the correct way to do that. Is there any better way?
function bulkJob(sfdcRecords, resolve, reject, begin, end) {
begin = begin || 0;
end = end || 10000;
let records = sfdcRecords.slice(begin, end);
conn.sobject('MyObject__c').insertBulk(records, (err, rets) => {
if (err) {
reject(err);
} else {
if (end > sfdcRecords.length) {
resolve();
}
bulkJob(sfdcRecords, resolve, reject, end, end + 10000);
}
});
}