published_at is now the first-publish time (null for drafts, kept across edits
and unpublish/republish), slugs collide to -2/-3 and regenerate on retitle,
every error is {"error"} with 400/401/403/404/405/409 pinned, timestamps are
RFC 3339 UTC. GUIDELINES pins the contract; each backend passes the same 59-check
end-to-end script.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01128fhuZbgivaSJvtMf4s1G
11 lines
470 B
Python
11 lines
470 B
Python
from pymongo import AsyncMongoClient
|
|
from pymongo.asynchronous.database import AsyncDatabase
|
|
|
|
|
|
async def connect(mongo_url: str, db_name: str) -> tuple[AsyncMongoClient, AsyncDatabase]:
|
|
client = AsyncMongoClient(mongo_url, tz_aware=True)
|
|
db = client[db_name]
|
|
await db.users.create_index("email", unique=True)
|
|
await db.posts.create_index("slug", unique=True)
|
|
await db.posts.create_index([("published", 1), ("published_at", -1)])
|
|
return client, db
|