ahvn.klstore.mdb_store module¶

class ahvn.klstore.mdb_store.MongoKLStore(database=None, collection=None, name=None, condition=None, include=None, exclude=None, *args, **kwargs)[source]¶

Bases: BaseKLStore

MongoDB-backed KL store using the MongoUKFAdapter.

Provides efficient CRUD operations for BaseUKF objects in MongoDB. Uses MongoDB’s native operations for optimal performance.

Note

This store handles only CRUD operations without vector embeddings. Vector search capabilities are provided by MongoKLEngine.

Parameters:
  • database (str | None)

  • collection (str | None)

  • name (str)

  • condition (Callable | None)

  • include (list | None)

  • exclude (list | None)

__init__(database=None, collection=None, name=None, condition=None, include=None, exclude=None, *args, **kwargs)[source]¶

Initialize the MongoDB KL store.

Parameters:
  • database (Optional[str]) – MongoDB database name.

  • collection (Optional[str]) – MongoDB collection name.

  • name (Optional[str]) – Name of the KLStore instance. If None, defaults to collection name.

  • condition (Optional[Callable]) – Optional upsert/insert condition to apply to the KLStore. KLs that do not satisfy the condition will be ignored. If None, all KLs are accepted.

  • include (Optional[list]) – Optional list of fields to include in MongoDB documents.

  • exclude (Optional[list]) – Optional list of fields to exclude from MongoDB documents.

  • *args – Additional positional arguments for BaseKLStore.

  • **kwargs – Additional keyword arguments for mongo database configuration.

__len__()[source]¶

Get the number of documents in the store.

Returns:

Number of documents.

Return type:

int

close()[source]¶

Close the MongoDB connection.

flush(**kwargs)[source]¶

Flush any pending operations (no-op for MongoDB as writes are immediate).