4.8 KiB
☁ (📎 / 🦏 💽) 💽
FastAPI 💪 🛠️ ⏮️ 🙆 ☁.
📥 👥 🔜 👀 🖼 ⚙️ 🗄, 📄 🧢 ☁ 💽.
👆 💪 🛠️ ⚫️ 🙆 🎏 ☁ 💽 💖:
- ✳
- 👸
- ✳
- 🇸🇲
- ✳, ♒️.
!!! tip 📤 🛂 🏗 🚂 ⏮️ FastAPI & 🗄, 🌐 ⚓️ 🔛 ☁, 🔌 🕸 & 🌖 🧰: https://github.com/tiangolo/full-stack-fastapi-couchbase
🗄 🗄 🦲
🔜, 🚫 💸 🙋 🎂, 🕴 🗄:
{!../../../docs_src/nosql_databases/tutorial001.py!}
🔬 📉 ⚙️ "📄 🆎"
👥 🔜 ⚙️ ⚫️ ⏪ 🔧 🏑 type 👆 📄.
👉 🚫 ✔ 🗄, ✋️ 👍 💡 👈 🔜 ℹ 👆 ⏮️.
{!../../../docs_src/nosql_databases/tutorial001.py!}
🚮 🔢 🤚 Bucket
🗄, 🥡 ⚒ 📄, 👈 💪 🎏 🆎.
👫 🛎 🌐 🔗 🎏 🈸.
🔑 🔗 💽 🌏 🔜 "💽" (🎯 💽, 🚫 💽 💽).
🔑 ✳ 🔜 "🗃".
📟, Bucket 🎨 👑 🇨🇻 📻 ⏮️ 💽.
👉 🚙 🔢 🔜:
- 🔗 🗄 🌑 (👈 💪 👁 🎰).
- ⚒ 🔢 ⏲.
- 🔓 🌑.
- 🤚
Bucket👐.- ⚒ 🔢 ⏲.
- 📨 ⚫️.
{!../../../docs_src/nosql_databases/tutorial001.py!}
✍ Pydantic 🏷
🗄 "📄" 🤙 "🎻 🎚", 👥 💪 🏷 👫 ⏮️ Pydantic.
User 🏷
🥇, ➡️ ✍ User 🏷:
{!../../../docs_src/nosql_databases/tutorial001.py!}
👥 🔜 ⚙️ 👉 🏷 👆 ➡ 🛠️ 🔢,, 👥 🚫 🔌 ⚫️ hashed_password.
UserInDB 🏷
🔜, ➡️ ✍ UserInDB 🏷.
👉 🔜 ✔️ 💽 👈 🤙 🏪 💽.
👥 🚫 ✍ ⚫️ 🏿 Pydantic BaseModel ✋️ 🏿 👆 👍 User, ↩️ ⚫️ 🔜 ✔️ 🌐 🔢 User ➕ 👩❤👨 🌅:
{!../../../docs_src/nosql_databases/tutorial001.py!}
!!! note
👀 👈 👥 ✔️ hashed_password & type 🏑 👈 🔜 🏪 💽.
✋️ ⚫️ 🚫 🍕 🏢 `User` 🏷 (1️⃣ 👥 🔜 📨 *➡ 🛠️*).
🤚 👩💻
🔜 ✍ 🔢 👈 🔜:
- ✊ 🆔.
- 🏗 📄 🆔 ⚪️➡️ ⚫️.
- 🤚 📄 ⏮️ 👈 🆔.
- 🚮 🎚 📄
UserInDB🏷.
🏗 🔢 👈 🕴 💡 🤚 👆 👩💻 ⚪️➡️ username (⚖️ 🙆 🎏 🔢) 🔬 👆 ➡ 🛠️ 🔢, 👆 💪 🌖 💪 🏤-⚙️ ⚫️ 💗 🍕 & 🚮 ⚒ 💯 ⚫️:
{!../../../docs_src/nosql_databases/tutorial001.py!}
Ⓜ-🎻
🚥 👆 🚫 😰 ⏮️ f"userprofile::{username}", ⚫️ 🐍 "Ⓜ-🎻".
🙆 🔢 👈 🚮 🔘 {} Ⓜ-🎻 🔜 ↔ / 💉 🎻.
dict 🏗
🚥 👆 🚫 😰 ⏮️ UserInDB(**result.value), ⚫️ ⚙️ dict "🏗".
⚫️ 🔜 ✊ dict result.value, & ✊ 🔠 🚮 🔑 & 💲 & 🚶♀️ 👫 🔑-💲 UserInDB 🇨🇻 ❌.
, 🚥 dict 🔌:
{
"username": "johndoe",
"hashed_password": "some_hash",
}
⚫️ 🔜 🚶♀️ UserInDB :
UserInDB(username="johndoe", hashed_password="some_hash")
✍ 👆 FastAPI 📟
✍ FastAPI 📱
{!../../../docs_src/nosql_databases/tutorial001.py!}
✍ ➡ 🛠️ 🔢
👆 📟 🤙 🗄 & 👥 🚫 ⚙️ 🥼 🐍 await 🐕🦺, 👥 🔜 📣 👆 🔢 ⏮️ 😐 def ↩️ async def.
, 🗄 👍 🚫 ⚙️ 👁 Bucket 🎚 💗 "🧵Ⓜ",, 👥 💪 🤚 🥡 🔗 & 🚶♀️ ⚫️ 👆 🚙 🔢:
{!../../../docs_src/nosql_databases/tutorial001.py!}
🌃
👆 💪 🛠️ 🙆 🥉 🥳 ☁ 💽, ⚙️ 👫 🐩 📦.
🎏 ✔ 🙆 🎏 🔢 🧰, ⚙️ ⚖️ 🛠️.