Skip to content

mongo - feat: moving to more robust options and properties#1872

Merged
jaredwray merged 2 commits intomainfrom
mongo---feat-moving-to-more-robust-options-and-properties
Feb 25, 2026
Merged

mongo - feat: moving to more robust options and properties#1872
jaredwray merged 2 commits intomainfrom
mongo---feat-moving-to-more-robust-options-and-properties

Conversation

@jaredwray
Copy link
Owner

@jaredwray jaredwray commented Feb 25, 2026

Please check if the PR fulfills these requirements

  • Followed the Contributing and Code of Conduct guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
mongo - feat: moving to more robust options and properties

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jaredwray, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly overhauls the configuration and property management within the MongoDB storage adapter. The primary goal was to introduce a more robust and flexible way to handle adapter options, moving away from a single opts object to distinct private properties with public accessors. This change improves the clarity of the adapter's internal state, simplifies option merging, and provides a cleaner, more maintainable API for users to configure their MongoDB Keyv instances. The documentation and test suite have been updated to reflect these architectural improvements.

Highlights

  • Refactored Configuration Management: The KeyvMongo class has been refactored to use private properties with public getters and setters for all configuration options, enhancing encapsulation and providing a more robust API for managing adapter settings.
  • Improved Constructor Option Handling: The constructor now intelligently merges options from a URI string, an options object, and additional options, ensuring a flexible and predictable configuration process. Keyv-specific options are now distinctly separated from MongoDB driver options.
  • Updated Documentation: The README.md has been significantly updated to include a detailed 'Table of Contents', 'Constructor Options' table, and a comprehensive 'Properties' section, clearly outlining all available configuration options and their usage.
  • Enhanced Test Coverage: New tests have been added to validate the default values of the new properties, their correct assignment via constructor options, their mutability through setters, and the backward compatibility of the opts getter.
Changelog
  • storage/mongo/README.md
    • Added a 'Table of Contents' for improved navigation.
    • Introduced detailed 'Constructor Options' documentation, including examples for URI strings and options objects.
    • Added a comprehensive 'Properties' section, documenting each configurable property with its type, default, and usage examples.
  • storage/mongo/src/index.ts
    • Replaced the keyvMongoKeys constant with a new private property-based configuration system.
    • Implemented private properties (_url, _collection, _namespace, _useGridFS, _db, _readPreference, _mongoOptions) to manage adapter state.
    • Added public getters and setters for all primary configuration properties (url, collection, namespace, useGridFS, db, readPreference).
    • Refactored the constructor to parse and merge configuration options more robustly, supporting string URIs and options objects.
    • Introduced extractMongoOptions to filter Keyv-specific options and pass remaining options to the MongoDB client.
    • Encapsulated connection initialization logic into a new initConnection private method.
    • Updated all internal method calls (e.g., get, set, clear) to use the new private properties instead of the opts object.
    • Modified the opts getter to provide backward compatibility by returning an object reflecting the current configuration.
  • storage/mongo/src/types.ts
    • Removed serialize, deserialize, and dialect properties from the Options type.
    • Extended the Options type to include MongoClientOptions for better type safety and pass-through of MongoDB driver options.
    • Removed the unused PifyFunction type definition.
  • storage/mongo/test/test.ts
    • Updated existing tests to assert against the new public properties and the backward-compatible opts getter.
    • Added new test cases to verify default property values.
    • Included tests to confirm properties can be correctly set via the constructor.
    • Implemented tests to ensure properties can be modified using their respective setters.
    • Added a test to validate the structure and content of the opts getter for backward compatibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 090628f2d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly refactors the configuration handling for the Keyv MongoDB storage adapter. The KeyvMongo class now uses individual private properties with public getters and setters for its configuration options (e.g., url, collection, namespace, useGridFS, db, readPreference), replacing the previous single opts object. This change improves type safety, encapsulation, and allows for dynamic modification of settings after instantiation. The constructor logic has been updated to parse options into these new properties, and a new extractMongoOptions method separates Keyv-specific options from those passed directly to the MongoDB client. The Options type has been streamlined to directly extend MongoClientOptions, and extensive JSDoc comments have been added to the codebase. The README.md has been updated with a table of contents and detailed documentation for the new constructor options and properties. New test cases were added to validate the default property values, constructor-based configuration, setter functionality, and to ensure backward compatibility for the opts getter. There were no specific review comments provided for these changes.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.96%. Comparing base (4bac033) to head (e83a838).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1872   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          32       32           
  Lines        2698     2747   +49     
  Branches      473      483   +10     
=======================================
+ Hits         2697     2746   +49     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray jaredwray merged commit b18aa28 into main Feb 25, 2026
10 checks passed
@jaredwray jaredwray deleted the mongo---feat-moving-to-more-robust-options-and-properties branch February 25, 2026 20:53
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