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)[源代码]

基类: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.

备注

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

参数:
  • 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)[源代码]

Initialize the MongoDB KL store.

参数:
  • 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__()[源代码]

Get the number of documents in the store.

返回:

Number of documents.

返回类型:

int

close()[源代码]

Close the MongoDB connection.

flush(**kwargs)[源代码]

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