The job/jobs returned from boss.fetch(name) do not have a done method, but rather it seems (according to the tests) that I must call boss.complete(job.id) to mark the job as completed.
const jobName = 'email-daily-digest';
const batchSize = 20;
boss.fetch(jobName, batchSize)
.then(jobs => {
if(!jobs) return;
console.log(`received ${jobs.length} ${jobName} jobs`);
// our magical emailer knows what to do with job.data
let promises = jobs.map(job => emailer.send(job.data).then(() => job.done()));
return Promise.all(promises);
})
.catch(error => console.log(error));
The above is an example for the fetch documentation in the usage docs, but it incorrectly shows a job being marked as completed with the done function.
While I don't understand why a job that was manually fetched has a different interface as one coming from subscribe, we should at least fix the documentation.
Note, I have a commit locally that fixes the documentation, but don't have proper permissions to push to origin.
The job/jobs returned from boss.fetch(name) do not have a
done
method, but rather it seems (according to the tests) that I must callboss.complete(job.id)
to mark the job as completed.https://github.com/timgit/pg-boss/blob/master/docs/usage.md#fetchname-batchsize
The above is an example for the
fetch
documentation in theusage
docs, but it incorrectly shows a job being marked as completed with thedone
function.While I don't understand why a job that was manually fetched has a different interface as one coming from subscribe, we should at least fix the documentation.
Note, I have a commit locally that fixes the documentation, but don't have proper permissions to push to origin.