swarmauri.standard.document_stores.base.DocumentStoreBase module

class swarmauri.standard.document_stores.base.DocumentStoreBase.DocumentStoreBase[source]

Bases: IDocumentStore, ABC

Abstract base class for document stores, implementing the IDocumentStore interface.

This class provides a standard API for adding, updating, getting, and deleting documents in a store. The specifics of storing (e.g., in a database, in-memory, or file system) are to be implemented by concrete subclasses.

abstract add_document(document)[source]

Add a single document to the document store.

Parameters: - document (IDocument): The document to be added to the store.

Return type:

None

abstract add_documents(documents)[source]

Add multiple documents to the document store in a batch operation.

Parameters: - documents (List[IDocument]): A list of documents to be added to the store.

Return type:

None

abstract delete_document(doc_id)[source]

Delete a document from the document store by its identifier.

Parameters: - doc_id (str): The unique identifier of the document to delete.

Return type:

None

document_count()[source]
dump(file_path)[source]
abstract get_all_documents()[source]

Retrieve all documents stored in the document store.

Returns: - List[IDocument]: A list of all documents in the store.

Return type:

List[IDocument]

abstract get_document(doc_id)[source]

Retrieve a single document by its identifier.

Parameters: - doc_id (str): The unique identifier of the document to retrieve.

Returns: - Optional[IDocument]: The requested document if found; otherwise, None.

Return type:

Optional[IDocument]

load(file_path)[source]
abstract update_document(doc_id, updated_document)[source]

Update a document in the document store.

Parameters: - doc_id (str): The unique identifier of the document to update. - updated_document (IDocument): The updated document instance.

Return type:

None