Class Job<T>

Represents an async job in a Database.

Type Parameters

  • T = any

Hierarchy

  • Job

Accessors

  • get isLoaded(): boolean
  • Whether the job's results have been loaded. If set to true, the job's result can be accessed from result.

    Returns boolean

  • get result(): undefined | T
  • The job's result if it has been loaded or undefined otherwise.

    Returns undefined | T

Methods

  • Cancels the job if it is still running. Note that it may take some time to actually cancel the job.

    Returns Promise<void>

  • Deletes the result if it has not already been retrieved or deleted.

    Returns Promise<void>

  • Fetches the job's completion state.

    Returns true if the job has completed, false otherwise.

    Example

    // poll for the job to complete
    while (!(await job.getCompleted())) {
    await timeout(1000);
    }
    // job result is now available and can be loaded
    await job.load();
    console.log(job.result);

    Returns Promise<boolean>

  • Loads the job's result from the database if it is not already loaded.

    Example

    // poll for the job to complete
    while (!job.isLoaded) {
    await timeout(1000);
    const result = await job.load();
    console.log(result);
    }
    // job result is now loaded and can also be accessed from job.result
    console.log(job.result);

    Returns Promise<undefined | T>

Generated using TypeDoc