Skip to content

feat(34): allow update functions to return the symbol NO_UPDATE - #38

Merged
LucVidal360 merged 5 commits into
mainfrom
main-34-noop-update
Jul 22, 2026
Merged

LucVidal360 merged 5 commits into
mainfrom
main-34-noop-update

Conversation

@LucVidal360

Copy link
Copy Markdown
Contributor

Context

  • The update option of MongoBulkDataMigration can be a function
    • called for each document to update
    • returning the desired document update ({ $set: xxx })
  • We can detect only at runtime that a document doesn't really need to be updated
    • e.g., the update function requests another collection to decide what should be updated
  • No need to send a no-op request to MongoDB in this case!

Changes

  • commits 1 and 2: boyscoutings
  • commits 3 and 4: allow update functions to return a new NO_UPDATE symbol
    • note that the progress logging was produced when calling bulk updates
    • but now, bulk updates don't necessarily hold all fetched documents (ignored ones are skipped)
    • so the progress logging is moved higher in the document loop
  • commit 5: bump new version

No need to count bulk operations, it already counts them itself.
The test didn't work because the validation schema set up in the
test fixture was incorrect:
- no `_id` field
- `properties` and `additionalProperties` no placed under `$jsonSchema`
@LucVidal360 LucVidal360 self-assigned this Jul 21, 2026
@LucVidal360
LucVidal360 requested a review from pp0rtal as a code owner July 21, 2026 08:55

@orca-security-eu orca-security-eu Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

This commit breaks the progress logs, as they are performed by
the bulk holders (`BackupBulk`, `MigrationBulk` and `RollbackBulk`),
which count the number of documents they are fed.

We'll address that next.
As the various `XXXBulkOperation` classes cannot know reliably the
number of treated documents, I'm moving the progress logging directly
in `MongoBulkDataMigration`.

@pp0rtal pp0rtal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucVidal360 Perfect with the fix on progress
Thank you for unskipping the extra test too 👍

Comment on lines +279 to +281
if (updateQuery === NO_UPDATE) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks the progress logs, as they are performed by

@LucVidal360 I was first not convinced by this return. I wondered if there was a way to not break the resumability of MBDM. But resumablity relies on update docs anyway which is not even alays possible.
If we choose in the future to store in the backup docs, there will be a little drawback to not store an empty backup, but this is not a big deal.

@Jordanlelay Jordanlelay left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread __tests__/MongoBulkDataMigration.update.test.ts
@LucVidal360
LucVidal360 merged commit dd33515 into main Jul 22, 2026
8 checks passed
@LucVidal360

Copy link
Copy Markdown
Contributor Author

@pp0rtal Help, how can I publish the new 1.8.1 version to npm?

npm error code ENEEDAUTH
npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
npm error need auth You need to authorize this machine using npm adduser

@LucVidal360
LucVidal360 deleted the main-34-noop-update branch July 23, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants