Skip to content

feat(database): add atomic find-and-update - #14

Merged
KilianBoute merged 1 commit into
mainfrom
feat/find-one-and-update
Aug 13, 2026
Merged

KilianBoute merged 1 commit into
mainfrom
feat/find-one-and-update

Conversation

@KilianBoute

@KilianBoute KilianBoute commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Description

Adds atomic FindOneAndUpdate support to the database abstraction layer and MongoDB implementation.

This change closes a gap in the current API where callers had to perform separate read and update operations, which can introduce race conditions in concurrent environments. By exposing MongoDB’s atomic find-and-update capability through DatabaseInterface, consumers can safely update and retrieve a document in a single operation.

The update also extends the mock database to fully support the new method, including:

  • configurable responses
  • queued sequential responses
  • call tracking
  • reset handling

This improves testability for components that depend on atomic update flows and keeps the mock feature set aligned with the production implementation.

Additional compile-time interface assertions were added for both MockDatabase and MongoClient, helping catch interface drift early during development.

Expose FindOneAndUpdate through DatabaseInterface and implement it for MongoDB.

Add mock responses, queues, call tracking, reset support, and regression tests for atomic update behavior.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.57143% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mongodb.go 0.00% 7 Missing ⚠️
pkg/database/mock.go 85.71% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@KilianBoute
KilianBoute merged commit 76f9222 into main Aug 13, 2026
6 checks passed
@KilianBoute
KilianBoute deleted the feat/find-one-and-update branch August 13, 2026 10:19
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.

1 participant