Files
site11/services/users/backend/models.py
jungwoo choi 683305918c Step 3: MongoDB and Redis integration complete
- Added MongoDB and Redis containers to docker-compose
- Integrated Users service with MongoDB using Beanie ODM
- Replaced in-memory storage with persistent MongoDB
- Added proper data models with email validation
- Verified data persistence with MongoDB ObjectIDs

Services running:
- MongoDB: Port 27017 (with health checks)
- Redis: Port 6379 (with health checks)
- Users service: Connected to MongoDB
- Console: API Gateway routing working

Test: Users now stored in MongoDB with persistence

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 16:21:32 +09:00

24 lines
653 B
Python

from beanie import Document
from pydantic import EmailStr, Field
from datetime import datetime
from typing import Optional
class User(Document):
username: str = Field(..., unique=True)
email: EmailStr
full_name: Optional[str] = None
created_at: datetime = Field(default_factory=datetime.now)
updated_at: datetime = Field(default_factory=datetime.now)
class Settings:
collection = "users"
class Config:
json_schema_extra = {
"example": {
"username": "john_doe",
"email": "john@example.com",
"full_name": "John Doe"
}
}