from datetime import datetime from app.services.firebase import db COLLECTION = "notes" import logging def create_note(note_id: str, payload: dict): now = datetime.utcnow() payload.update({ "status": "created", "created_at": now, "updated_at": now }) logging.info(f"[NoteService] create_note: id={note_id}, keys={list(payload.keys())}") db.collection(COLLECTION).document(note_id).set(payload) logging.info(f"[NoteService] create_note: saved id={note_id}") def update_note(note_id: str, data: dict = None, status: str = None): updates = {"updated_at": datetime.utcnow()} if data: updates.update(data) if status: updates["status"] = status db.collection(COLLECTION).document(note_id).update(updates) def get_note(note_id: str): logging.info(f"[NoteService] get_note: id={note_id}") doc = db.collection(COLLECTION).document(note_id).get() logging.info(f"[NoteService] get_note: exists={doc.exists}") return doc.to_dict() if doc.exists else None