Skip to content

Job.getCleanCopy

Grant Carthew edited this page Aug 17, 2016 · 11 revisions

Method Signature

Job.getCleanCopy(priorityAsString)

Parameter: priorityAsString - true or false value to return the numeric or string bases priority.

Returns: A JavaScript Object populated with the properties of the job.

Example:

let jobData = job.getCleanCopy()
// jobData.priority will be a number.

Description

This method is mostly used within the rethinkdb-job-queue to save the jobs to the database. You can use this method if you want a copy of the job properties.

The returned job object has all methods and the reference to the owning Queue removed leaving only the jobs properties.

Depending if you pass in a true or false the Job.priority value will be either an Integer or a String. See the Job Options document for more detail.

Examples

The following is an example of what will be returned by Job.getCleanCopy when passing in a true value to priorityAsString. The property priority would be the number 40 if we did not set priorityAsString to true.

{ dateCreated: 2016-08-17T00:31:39.155Z,
  dateRetry: 2016-08-17T00:31:39.155Z,
  id: 'c7f759f2-53b7-4fa4-9cce-d45edbf23541',
  log:
   [ { date: 2016-08-17T00:31:39.280Z,
       message: 'Job added to the queue',
       queueId: 'WebDev:rjqJobQueue:rjqJobList:7210:01139a04-7c54-4e09-8a66-54fde8c5a059',
       retryCount: 0,
       status: 'added',
       type: 'information' } ],
  payload: 'job data goes here',
  priority: 'normal',
  progress: 0,
  queueId: 'WebDev:rjqJobQueue:rjqJobList:7210:01139a04-7c54-4e09-8a66-54fde8c5a059',
  retryCount: 0,
  retryDelay: 600,
  retryMax: 3,
  status: 'added',
  timeout: 300 }

This example is simply showing how to call Job.getCleanCopy. Notice the priorityAsString parameter is not being passed. The returned priority value will be 40.

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

const job = queue.createJob()
const cleanCopy = job.getcleanCopy()

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally