Skip to content

Queue.containsJobByName

Grant Carthew edited this page Feb 10, 2017 · 3 revisions

Method Signature

Queue.containsJobByName(name)

Parameter: name String

  • name can be any string value.

Returns: Promise => Boolean

  • True if the named job exists in the queue, otherwise False.

Example:

q.containsJobByName('batman'}).then((exist) => {
  exist ? console.log('batman job exists')
    : console.log('batman job does not exist')
}).catch(err => console.error(err))

Description

This method is syntax sugar wrapping the Queue.findJobByName method call. If a job with the Job.name property equal to the name value exists, you will get a true result.

You will get a true result from the query no matter what the values assigned to the jobs in the queue are. If the job has the same name as your query and has completed processing you will still get a true result.

For more detailed analysis of the named jobs, use the Queue.findJobByName method.

If you are not setting the Job.name property, do not use this method. Instead use the Queue.getJob method supplying the Job.id.

Examples

This is a simple example checking for a named jobs existence.

const Queue = require('rethinkdb-job-queue')
const q = new Queue()

let job = q.createJob({ name: '12345678' })

q.containsJobByName('12345678').then((exists) => {
  // The returned 'exists' value will be 'true'
}).catch(err => console.error(err))

Related Documents

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally