Skip to content

feature/make-options-agnostic-add-insert-methods#3

Merged
cedricve merged 1 commit intomainfrom
feature/make-options-agnostic-add-insert-methods
Jan 12, 2026
Merged

feature/make-options-agnostic-add-insert-methods#3
cedricve merged 1 commit intomainfrom
feature/make-options-agnostic-add-insert-methods

Conversation

@cedricve
Copy link
Member

@cedricve cedricve commented Jan 12, 2026

Description

Pull Request: feature/make-options-agnostic-add-insert-methods

Description

This pull request introduces a series of changes aimed at making the database options agnostic and adding insert methods to enhance the flexibility and functionality of the project.

Motivation

  1. Agnostic Database Options:

    • Previously, the Database struct was tightly coupled with MongoOptions, making it difficult to extend or integrate other types of databases or message queues.
    • By introducing a generic DatabaseOptions interface, we enable the Database struct to accept any type of options that implement the Validate method. This change increases modularity and allows for easier integration with various backends.
  2. Addition of Insert Methods:

    • The addition of InsertOne and InsertMany methods to the DatabaseInterface and their implementations in MongoClient enhances the CRUD capabilities of the project.
    • This change allows for robust data insertion operations, making the database interactions more comprehensive and versatile.

Changes

  1. Database Options Interface:

    • Introduced DatabaseOptions interface with a Validate method.
    • Updated the Database struct to use DatabaseOptions instead of MongoOptions.
    • Modified the New function to handle different types of options by type assertion.
  2. Insert Methods in Database Interface:

    • Added InsertOne and InsertMany methods to the DatabaseInterface.
    • Implemented these methods in the MongoClient.
  3. Mock Database Adjustments:

    • Updated MockDatabase to include stubs for InsertOne and InsertMany methods.
  4. MongoClient Enhancements:

    • Implemented InsertOne and InsertMany methods.
    • Added Validate method to MongoOptions.
  5. Tests:

    • Updated tests to reflect changes in the database options.
    • Added tests for the new insert methods.

Impact

  • Flexibility: The project is now more flexible and can easily integrate different types of databases or message queues by implementing the DatabaseOptions interface.
  • Enhanced Functionality: With the addition of insert methods, the database module becomes more powerful, supporting comprehensive data manipulation operations.
  • Modularity: The decoupling of database options from a specific type (MongoDB) enhances the modularity of the project, making it easier to maintain and extend.

This change significantly improves the project's architecture and functionality, paving the way for future enhancements and integrations.

Extended DatabaseInterface with InsertOne, InsertMany, and Disconnect methods. Implemented these methods for MongoClient and MockDatabase. Refactored DatabaseOptions to support validation and updated related code and tests for improved flexibility and functionality.
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 10.71429% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/database/mongodb.go 0.00% 17 Missing ⚠️
pkg/database/mock.go 0.00% 6 Missing ⚠️
pkg/database/database.go 60.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cedricve cedricve merged commit 75aab7d into main Jan 12, 2026
6 checks passed
@cedricve cedricve deleted the feature/make-options-agnostic-add-insert-methods branch January 12, 2026 21:42
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