Spaces:
Sleeping
Sleeping
| from datetime import datetime | |
| from .. import db | |
| class GratitudeEntry(db.Model): | |
| """One gratitude journal entry per user per save.""" | |
| __tablename__ = "gratitude_entries" | |
| id = db.Column(db.Integer, primary_key=True) | |
| user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False) | |
| created_at = db.Column(db.DateTime, default=datetime.utcnow, index=True) | |
| content = db.Column(db.Text, nullable=False) # main journal text | |
| mood = db.Column(db.String(32), nullable=True) # optional emoji/mood tag | |
| items = db.Column(db.JSON, nullable=True) # list of 3 gratitude bullet points | |
| def to_dict(self): | |
| return { | |
| "id": self.id, | |
| "user_id": self.user_id, | |
| "created_at": self.created_at.isoformat(), | |
| "content": self.content, | |
| "mood": self.mood, | |
| "items": self.items or [], | |
| } | |