From 2822f743fe09c0af27f04af10f250f708f9653c1 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:30:02 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=20Remove=20`visible`=20when=20acki?= =?UTF-8?q?ng=20jobs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a non-breaking change that forms part of the migration path to improving our performance in https://github.com/reedsy/mongodb-queue/pull/15 When acking a job, we now unset the `visible` property, which makes `visible` and `deleted` mutually exclusive properties, so that the presence of one implies the absence of the other. We can do this, because the only time we query on `visible` is when we *also* query for `deleted: {$exists: false}`. Similarly, the only times we query for `deleted: {$exists: true}` are times when we don't query `visible`. --- mongodb-queue.ts | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mongodb-queue.ts b/mongodb-queue.ts index 25ba41b..ce91682 100644 --- a/mongodb-queue.ts +++ b/mongodb-queue.ts @@ -208,6 +208,9 @@ export class MongoDBQueue { $set: { deleted: now(), }, + $unset: { + visible: 1, + }, }; const options = { returnDocument: 'after', diff --git a/package.json b/package.json index bd254b5..bab7c97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reedsy/mongodb-queue", - "version": "7.1.0", + "version": "7.1.1", "description": "Message queues which uses MongoDB.", "main": "mongodb-queue.js", "scripts": {