Updated this to the latest version of develop, got rid of most of the duplication, might be missing some packages in toml, needs testing

This commit is contained in:
Carlos Mesquita
2024-08-30 02:35:11 +01:00
parent 3cf9fa5cba
commit f92a803d96
73 changed files with 3642 additions and 2703 deletions

View File

@@ -11,3 +11,6 @@ class IDocumentStore(ABC):
async def get_all(self, collection: str):
pass
async def get_doc_by_id(self, collection: str, doc_id: str):
pass

View File

@@ -15,9 +15,9 @@ class Firestore(IDocumentStore):
update_time, document_ref = await collection_ref.add(item)
if document_ref:
self._logger.info(f"Document added with ID: {document_ref.id}")
return True, document_ref.id
return document_ref.id
else:
return False, None
return None
async def save_to_db_with_id(self, collection: str, item, id: str):
collection_ref: AsyncCollectionReference = self._client.collection(collection)
@@ -26,9 +26,9 @@ class Firestore(IDocumentStore):
doc_snapshot = await document_ref.get()
if doc_snapshot.exists:
self._logger.info(f"Document added with ID: {document_ref.id}")
return True, document_ref.id
return document_ref.id
else:
return False, None
return None
async def get_all(self, collection: str):
collection_ref: AsyncCollectionReference = self._client.collection(collection)
@@ -36,3 +36,12 @@ class Firestore(IDocumentStore):
async for doc in collection_ref.stream():
docs.append(doc.to_dict())
return docs
async def get_doc_by_id(self, collection: str, doc_id: str):
collection_ref: AsyncCollectionReference = self._client.collection(collection)
doc_ref: AsyncDocumentReference = collection_ref.document(doc_id)
doc = await doc_ref.get()
if doc.exists:
return doc.to_dict()
return None