ahvn.utils.mdb.mdb_utils module

MongoDB configuration utilities for AgentHeaven.

This module provides functions to parse and resolve MongoDB configurations similar to how database configurations are handled. It supports multiple MongoDB providers and generates PyMongo-ready configurations with connection strings and parameters.

ahvn.utils.mdb.mdb_utils.resolve_mdb_config(database=None, collection=None, **kwargs)[源代码]

Compile a MongoDB configuration dictionary based on the following order of priority: 1. kwargs 2. global configuration When a parameter is specified in multiple places, the one with the highest priority is used.

参数:
  • database (str, optional) -- The database name to use.

  • collection (str, optional) -- The collection name to use.

  • **kwargs -- Additional parameters to override in the configuration.

返回:

The resolved MongoDB configuration dictionary.

返回类型:

Dict[str, Any]

示例

>>> config = resolve_mdb_config(collection="my_collection")
>>> config = resolve_mdb_config(host="192.168.1.100")
>>> config = resolve_mdb_config(connection_string="mongodb://localhost:27017/mydb")