Usage
Get Jobs
To get a job by its ID:
const job = await jobQueue.getJob(jobId);
To get all jobs:
const jobs = await jobQueue.getAllJobs(limit, offset);
To get jobs by status:
const jobs = await jobQueue.getJobsByStatus(status, limit, offset);
Get Jobs by Tags
You can get jobs by their tags using the getJobsByTags
method:
const jobs = await jobQueue.getJobsByTags(['welcome', 'user'], 'all', 10, 0);
- The first argument is an array of tags to match.
- The second argument is the tag query mode. See Tags for more details.
- The third and fourth arguments are optional for pagination.
Get Jobs by Filter
You can retrieve jobs using multiple filters with the getJobs
method:
const jobs = await jobQueue.getJobs(
{
jobType: 'email',
priority: 2,
runAt: { gte: new Date('2024-01-01'), lt: new Date('2024-02-01') },
tags: { values: ['welcome', 'user'], mode: 'all' },
},
10,
0,
);
- The first argument is an optional filter object. You can filter by:
jobType
: The job type (string).priority
: The job priority (number).runAt
: The scheduled time. You can use aDate
for exact match, or an object withgt
,gte
,lt
,lte
, oreq
for range queries.tags
: An object withvalues
(array of tags) andmode
(see Tags).
- The second and third arguments are optional for pagination (
limit
,offset
).
You can combine any of these filters. If no filters are provided, all jobs are returned (with pagination if specified).