Ajout du backend

This commit is contained in:
2026-09-25 13:58:11 +02:00
parent 3a6a849c5a
commit 450300ddf6
4 changed files with 202 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
class FirestoreStore:
def __init__(self, project_id, collection="measures"):
from google.cloud import firestore # import tardif : optionnel
self.db = firestore.Client(project=project_id)
self.collection = collection
def add_measure(self, measure):
self.db.collection(self.collection).add(measure)
def list_measures(self, device_id, limit=50):
docs = (
self.db.collection(self.collection)
.where("device_id", "==", device_id)
.limit(limit)
.stream()
)
return [d.to_dict() for d in docs]