MongoDBRecordManager#
- class langchain_mongodb.indexes.MongoDBRecordManager(collection: Collection)[source]#
A MongoDB-based implementation of the record manager.
Methods
__init__
(collection)Initialize the MongoDBRecordManager.
Create the database schema for the document manager.
adelete_keys
(keys)Asynchronously delete documents from the MongoDB collection.
aexists
(keys)Asynchronously check if the given keys exist in the MongoDB collection.
Asynchronously get the current server time as a timestamp.
alist_keys
(*[, before, after, group_ids, limit])Asynchronously list documents in the MongoDB collection based on the provided date range.
aupdate
(keys, *[, group_ids, time_at_least])Asynchronously upsert documents into the MongoDB collection.
close
()Close the resources used by the MongoDBRecordManager.
Create the database schema for the document manager.
delete_keys
(keys)Delete documents from the MongoDB collection.
exists
(keys)Check if the given keys exist in the MongoDB collection.
from_connection_string
(connection_string, ...)Construct a RecordManager from a MongoDB connection URI.
get_time
()Get the current server time as a timestamp.
list_keys
(*[, before, after, group_ids, limit])List documents in the MongoDB collection based on the provided date range.
update
(keys, *[, group_ids, time_at_least])Upsert documents into the MongoDB collection.
- Parameters:
collection (Collection)
- __init__(collection: Collection) None [source]#
Initialize the MongoDBRecordManager.
The record manager abstraction is used by the langchain indexing API. The record manager keeps track of which documents have been written into a vectorstore and when they were written. For more details, see the RecordManager API Docs.
- Parameters:
connection_string – A valid MongoDB connection URI.
db_name – The name of the database to use.
collection_name – The name of the collection to use.
collection (Collection)
- Return type:
None
- async acreate_schema() None [source]#
Create the database schema for the document manager.
- Return type:
None
- async adelete_keys(keys: Sequence[str]) None [source]#
Asynchronously delete documents from the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
None
- async aexists(keys: Sequence[str]) List[bool] [source]#
Asynchronously check if the given keys exist in the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
List[bool]
- async aget_time() float [source]#
Asynchronously get the current server time as a timestamp.
- Return type:
float
- async alist_keys(*, before: float | None = None, after: float | None = None, group_ids: Sequence[str] | None = None, limit: int | None = None) List[str] [source]#
Asynchronously list documents in the MongoDB collection based on the provided date range.
- Parameters:
before (float | None)
after (float | None)
group_ids (Sequence[str] | None)
limit (int | None)
- Return type:
List[str]
- async aupdate(keys: Sequence[str], *, group_ids: Sequence[str | None] | None = None, time_at_least: float | None = None) None [source]#
Asynchronously upsert documents into the MongoDB collection.
- Parameters:
keys (Sequence[str])
group_ids (Sequence[str | None] | None)
time_at_least (float | None)
- Return type:
None
- create_schema() None [source]#
Create the database schema for the document manager.
- Return type:
None
- delete_keys(keys: Sequence[str]) None [source]#
Delete documents from the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
None
- exists(keys: Sequence[str]) List[bool] [source]#
Check if the given keys exist in the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
List[bool]
- classmethod from_connection_string(connection_string: str, namespace: str) MongoDBRecordManager [source]#
Construct a RecordManager from a MongoDB connection URI.
- Parameters:
connection_string (str) – A valid MongoDB connection URI.
namespace (str) – A valid MongoDB namespace (in form f”{database}.{collection}”)
- Returns:
A new MongoDBRecordManager instance.
- Return type:
- list_keys(*, before: float | None = None, after: float | None = None, group_ids: Sequence[str] | None = None, limit: int | None = None) List[str] [source]#
List documents in the MongoDB collection based on the provided date range.
- Parameters:
before (float | None)
after (float | None)
group_ids (Sequence[str] | None)
limit (int | None)
- Return type:
List[str]