Skip to content

Commit

Permalink
lib/agenda/find-and-lock-next-job.ts - use enum ReturnDocument.AFTER …
Browse files Browse the repository at this point in the history
…from mongodb
  • Loading branch information
Pavel Svitek committed Jul 29, 2022
1 parent 42e9191 commit ffdcc9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/agenda/find-and-lock-next-job.ts
Expand Up @@ -2,6 +2,7 @@ import createDebugger from "debug";
import { createJob } from "../utils";
import { Agenda } from ".";
import { Job } from "../job";
import { ReturnDocument } from "mongodb";

const debug = createDebugger("agenda:internal:_findAndLockNextJob");

Expand Down Expand Up @@ -53,13 +54,12 @@ export const findAndLockNextJob = async function (
* Query used to affect what gets returned
* @type {{returnOriginal: boolean, sort: object}}
*/
const JOB_RETURN_QUERY = { returnDocument: "after", sort: this._sort };
const JOB_RETURN_QUERY = { returnDocument: ReturnDocument.AFTER, sort: this._sort };

// Find ONE and ONLY ONE job and set the 'lockedAt' time so that job begins to be processed
const result = await this._collection.findOneAndUpdate(
JOB_PROCESS_WHERE_QUERY,
JOB_PROCESS_SET_QUERY,
// @ts-ignore
JOB_RETURN_QUERY
);

Expand Down

0 comments on commit ffdcc9c

Please sign in to comment.