MongoDBRecordManager#
- class langchain_mongodb.indexes.MongoDBRecordManager(
- collection: Collection,
A MongoDB-based implementation of the record manager.
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)
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.
- __init__(
- collection: Collection,
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],
Asynchronously delete documents from the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
None
- async aexists(
- keys: Sequence[str],
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,
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,
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],
Delete documents from the MongoDB collection.
- Parameters:
keys (Sequence[str])
- Return type:
None
- exists(
- keys: Sequence[str],
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,
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 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]