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>
This commit is contained in:
24
services/users/backend/models.py
Normal file
24
services/users/backend/models.py
Normal file
@ -0,0 +1,24 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user