Skip to content

feature/add-find-into-method#5

Merged
cedricve merged 5 commits intomainfrom
feature/add-find-into-method
Jan 26, 2026
Merged

feature/add-find-into-method#5
cedricve merged 5 commits intomainfrom
feature/add-find-into-method

Conversation

@cedricve
Copy link
Member

@cedricve cedricve commented Jan 22, 2026

Description

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

Motivation

The primary motivation behind this pull request is to enhance the usability and flexibility of the database query operations within our project. By introducing the FindOne method with a fluent API, we aim to simplify the process of decoding query results directly into Go structs, thereby improving code readability and reducing boilerplate code. This feature is particularly useful for developers who frequently interact with MongoDB and need a more intuitive way to handle query results.

Improvements

  1. Improved Usability:

    • The FindOne method now returns a SingleResultInterface that provides a fluent API for decoding results directly into structs using the .Into() method. This eliminates the need for manual BSON decoding, making the code cleaner and more maintainable.
  2. Error Handling:

    • The SingleResultInterface includes an .Err() method to check for errors before attempting to decode the result. This ensures that errors are handled gracefully and prevents potential runtime issues.
  3. Raw Result Access:

    • The .Raw() method allows developers to access the raw BSON document if needed. This is useful for scenarios where the result needs to be processed in its raw form.
  4. Consistency Across Operations:

    • The UpdateOne method has also been updated to return an UpdateResultInterface, providing a consistent API for handling update operation results.
  5. Mocking and Testing:

    • The mock database implementation has been updated to support the new SingleResultInterface and UpdateResultInterface. This ensures that unit tests can accurately simulate and verify database interactions.
  6. Enhanced Documentation:

    • The README has been updated with examples and explanations of the new methods, making it easier for developers to understand and utilize the new features.

Overall, these improvements aim to streamline database operations within the project, making it easier for developers to write, understand, and maintain their code.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 11.51515% with 146 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mock.go 15.83% 99 Missing and 2 partials ⚠️
pkg/database/mongodb.go 0.00% 45 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cedricve cedricve merged commit b9ace10 into main Jan 26, 2026
6 checks passed
@cedricve cedricve deleted the feature/add-find-into-method branch January 26, 2026 08:12
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