Files
jimi-gallery/backend/db.py
yakenator 098b55e3b0 feat: initial Jimi Gallery prototype
- Public site (Home/Artists/Exhibitions/News/About/Contact) with EN/KO/JA i18n
- Admin panel with login, CRUD, image upload, multilingual editing
- Exhibition slider/lightbox view
- FastAPI + MongoDB backend, JWT auth
- Docker Compose deployment, behind nginx at jimi.yakenator.io
2026-04-25 12:47:36 +09:00

25 lines
622 B
Python

"""Mongo connection and collection accessors."""
import os
from motor.motor_asyncio import AsyncIOMotorClient
MONGO_URL = os.environ.get("MONGO_URL", "mongodb://localhost:27017")
DB_NAME = os.environ.get("DB_NAME", "jimi_gallery")
client = AsyncIOMotorClient(MONGO_URL)
db = client[DB_NAME]
artists = db.artists
exhibitions = db.exhibitions
news = db.news
settings_col = db.settings # single-document collection keyed by _id="singleton"
def strip_id(doc):
"""Drop Mongo's _id before returning to the client."""
if doc is None:
return None
doc = dict(doc)
doc.pop("_id", None)
return doc