Skip to content

feature/add-find-all-method#6

Merged
cedricve merged 1 commit intomainfrom
feature/add-find-all-method
Feb 4, 2026
Merged

feature/add-find-all-method#6
cedricve merged 1 commit intomainfrom
feature/add-find-all-method

Conversation

@cedricve
Copy link
Member

@cedricve cedricve commented Feb 4, 2026

Description

Pull Request: feature/add-find-all-method

Motivation

The primary motivation behind this change is to enhance our database querying capabilities by introducing a more fluent and flexible way to handle find query results. The current implementation of the Find method returns a raw result set that requires additional handling to process and decode. This can lead to repetitive boilerplate code and potential errors in handling query results.

Improvements

  1. Fluent API for Query Results:

    • Introduced the FindResultInterface, which provides a more structured and fluent API for handling query results.
    • Added the FindResult struct that implements the FindResultInterface, allowing methods like All to decode results directly into the provided destination slice.
  2. Enhanced Mocking Capabilities:

    • Updated the MockDatabase to support the new FindResultInterface, making it easier to write and maintain tests.
    • Added MockFindResult to simulate the behavior of FindResult in tests, ensuring consistency between production and test code.
  3. Simplified Result Handling:

    • The All method on FindResult simplifies the process of decoding query results, reducing the risk of errors and making the codebase cleaner.
    • The new approach allows for better error handling by encapsulating errors within the FindResult structure.
  4. Consistency and Readability:

    • By returning a FindResultInterface, the codebase achieves a consistent way of handling query results, improving readability and maintainability.
    • The changes ensure that the interface for database operations remains clean and intuitive, aligning with best practices for API design.

Overall, these changes aim to improve the developer experience by providing a more robust and user-friendly way to handle database query results, while also enhancing the testability and maintainability of the codebase.

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 44.64286% with 31 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mock.go 46.51% 19 Missing and 4 partials ⚠️
pkg/database/mongodb.go 38.46% 6 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@cedricve cedricve merged commit 4092e6b into main Feb 4, 2026
6 checks passed
@cedricve cedricve deleted the feature/add-find-all-method branch February 4, 2026 14:52
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