Jobs
pulse.jobs(query, sort, limit, skip)
pulse.jobs(query, sort, limit, skip)
Example Usage
const pulse = new Pulse();
// Fetch the first 10 completed jobs, skipping the first 5, sorted by creation date
pulse.jobs({ status: 'completed' }, { createdAt: -1 }, 10, 5)
.then(jobs => {
console.log('Retrieved completed jobs:', jobs);
})
.catch(error => {
console.error('Error fetching jobs:', error);
});
Parameters
query
(Filter<any>
- optional): A MongoDB filter object used to specify which jobs to retrieve. If no query is provided, all jobs in the database will be considered.sort
(Sort | string
- optional): A MongoDB sort object that specifies the order in which to return the jobs. If no sort is specified, jobs will be returned in their natural order.limit
(number
- optional): The maximum number of jobs to return. If not specified, or if specified as0
, no limit will be applied.skip
(number
- optional): The number of jobs to skip before starting to return the results. This can be used for pagination.
Returns
Promise<Job[]>
: A promise that resolves to an array ofJob
objects that match the query and adhere to the specified sorting and pagination settings.
Last updated
Was this helpful?