Implement recorrelation logic

This commit is contained in:
Logan
2026-04-21 22:19:57 -04:00
parent 338b946ba3
commit 65839a3191
5 changed files with 158 additions and 13 deletions
+18
View File
@@ -57,6 +57,24 @@ async def collection_list(collection: str, **filters) -> list[dict]:
return await asyncio.to_thread(_query)
async def collection_where(
collection: str,
conditions: list[tuple[str, str, Any]],
) -> list[dict]:
"""
Query a collection with arbitrary where-clauses.
conditions: list of (field, op, value) — e.g. [("ended_at", ">=", cutoff_dt)]
Supports any Firestore operator: "==", "!=", "<", "<=", ">", ">=".
"""
def _query():
ref = db.collection(collection)
for field, op, value in conditions:
ref = ref.where(field, op, value)
return [doc.to_dict() for doc in ref.stream()]
return await asyncio.to_thread(_query)
async def doc_delete(collection: str, doc_id: str) -> None:
ref = db.collection(collection).document(doc_id)
await asyncio.to_thread(ref.delete)