# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: MongoDB
spec:
    description: A source-available, cross-platform, document-oriented database program.
    coverImage: https://miro.medium.com/v2/resize:fit:1200/0*BmLKgrU_qFtakYsB.png
    icon: https://cdn.zeabur.com/marketplace/mongodb.svg
    tags:
        - Database
    readme: "# Deploying MongoDB\n\n**MongoDB** is a popular open-source, document-oriented NoSQL database. Instead of traditional rows and columns, it stores data in flexible, JSON-like documents, making it an excellent choice for modern web applications that require high performance and scalability.\n\nZeabur simplifies the process of setting up a database. Instead of managing Docker containers or configuring servers manually, you can deploy a fully functional MongoDB instance from the Marketplace with just one click.\n\n### What you will learn\n\nIn this tutorial, we will guide you through:\n\n1. Deploying a MongoDB service on Zeabur.\n2. Connecting to your database locally using **VS Code**, **Compass**, or **Mongosh**.\n3. Configuring your Node.js or Python application to talk to the database.\n\n---\n\n## Phase 1: Deploy the database\n\n### Step 1: Create the MongoDB Service\n\nZeabur offers a \"one-click deployment\", meaning you rarely need to configure complex settings manually.\n\n**Option 1: Create Postgresql instance from Project page**\n\n1. Log in to your [**Zeabur Dashboard**](https://zeabur.com/).\n2. Click the **\"New Project\"** button.\n3. Select **\"Template\"** (Marketplace).\n4. Search for `MongoDB`.\n5. Select the official MongoDB image. Your service will start deploying immediately.\n\n**Option 2: Create MongoDB instance from template page**\n\n1. Log in to your [**Zeabur Dashboard**](https://zeabur.com/).\n2. Select `Features` and `Template`.\n3. Choose or Search `MongoDB`.\n4. Select **MongoDB** (usually the official image) click `deploy` and it will start deploying.\n\n### Step 2: Get Your Connection String\n\n1. Go to the **Instruction** tab of the service.\n2. Copy the **MongoDB connection string** (URI).\n    - It looks like this:\n    `mongodb://mongo:xxxx@xxx.clusters.zeabur.com:25909`\n\n---\n\n## Phase 2: Connecting with database\n\n### Option A: Connect using VS Code\n\nThe best way to manage MongoDB in VS Code is using the official extension.\n\n1. **Install the Extension:**\n    - Go to the Extensions Marketplace.\n    - Search for **\"MongoDB for VS Code\"**.\n    - Install the one created by **MongoDB**.\n2. **Add Connection:**\n    - Click the **MongoDB Leaf Icon** that appears in your sidebar.\n    - Click **\"Add Connection\"**.\n    - Select **\"Connect with Connection String\"**.\n3. **Paste and Connect:**\n    - Paste the URL you copied from Zeabur in **Step 3**.\n    - Press `Enter`.\n    - You can now browse your Collections and Documents directly in the sidebar.\n\n---\n\n### Option B: Connect using MongoDB Compass (Official GUI)\n\nIf you want to visualize your data (tables, graphs, schema analysis), **MongoDB Compass** is the standard tool.\n\n1. Download and install [MongoDB Compass](https://www.mongodb.com/products/tools/compass).\n2. Open the application.\n3. In the **\"URI\"** box, paste the Connection String from Zeabur.\n4. Click **\"Connect\"**.\n    - *Troubleshooting:* If it fails, ensure you didn't accidentally copy the \"Internal\" host. The internal host usually ends in `.svc.cluster.local`, which won't work on your computer. The public host usually ends in `.zeabur.app`.\n\n---\n\n### Option C: Connect using M**ongosh**\n\n[**mongosh**](https://www.mongodb.com/docs/mongodb-shell/) is a fully-featured JavaScript and Node.js REPL environment for interacting with MongoDB databases.\n\nOnce you have downloaded and installed it according to the documentation, go back to your Zeabur dashboard. Click on the Connections tab in the MongoDB service, and click the eye icon to copy the connection string.\n![connect-path](https://cdn.zeabur.com/templates/mongodb/connect-path.png)\n\n```bash\nmongosh mongodb://<YOUR_CONNECT_PATH>\n\n```\n\nReplace **`<YOUR_CONNECT_PATH>`** with the connection string you just copied, and we can use the following command to test if the connection is successful:\n\n```bash\nuse mongodb_test\ndb.mongodb_test.insertOne({content: \"Hello World\"})\nshow dbs\n\n```\n\nIf successful, it should return:\n![mongosh-connect-success](https://cdn.zeabur.com/templates/mongodb/mongosh-connect-success.png)\n\nThen we can **`drop`** the test database.\n\n```bash\nuse mongodb_test\ndb.drop()\n```\n\n### \U0001F4A1 Important Note: \"Internal\" vs \"Public\"\n\n- **For Local Development:** Use the **Public** Domain you just set up.\n- **For Your Deployed App:** When you deploy your backend code (Node.js/Python) to Zeabur, change your `MONGO_URI` environment variable to use the **Internal** connection string (found in the \"Private\" section of the Connection tab).\n    - **Why?** The internal connection is much faster and does not count towards your public bandwidth usage."
    services:
        - name: mongodb
          icon: https://cdn.zeabur.com/marketplace/mongodb.svg
          template: PREBUILT
          spec:
            source:
                image: mongo:8
                command:
                    - sh
                args:
                    - -c
                    - sed -i '10,23d' /usr/local/bin/docker-entrypoint.sh && exec docker-entrypoint.sh mongod
            ports:
                - id: database
                  port: 27017
                  type: TCP
            volumes:
                - id: data
                  dir: /data/db
            instructions:
                - title: Command to connect to your MongoDB
                  content: mongosh "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}"
                - title: MongoDB connection string
                  content: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}
                - title: MongoDB username
                  content: ${MONGO_USERNAME}
                - title: MongoDB password
                  content: ${MONGO_PASSWORD}
                - title: MongoDB host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: MongoDB port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                MONGO_CONNECTION_STRING:
                    default: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}
                    expose: true
                MONGO_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                MONGO_INITDB_ROOT_PASSWORD:
                    default: ${PASSWORD}
                MONGO_INITDB_ROOT_USERNAME:
                    default: mongo
                MONGO_PASSWORD:
                    default: ${MONGO_INITDB_ROOT_PASSWORD}
                    expose: true
                MONGO_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                MONGO_URI:
                    default: ${MONGO_CONNECTION_STRING}
                    expose: true
                MONGO_USERNAME:
                    default: ${MONGO_INITDB_ROOT_USERNAME}
                    expose: true
localization:
    es-ES:
        description: Un programa de base de datos orientado a documentos, multiplataforma y con código fuente disponible.
        readme: "# Desplegando MongoDB\n\n**MongoDB** es una base de datos NoSQL popular, de código abierto y orientada a documentos. En lugar de filas y columnas tradicionales, almacena los datos en documentos flexibles similares a JSON, lo que la hace una excelente opción para aplicaciones web modernas que requieren alto rendimiento y escalabilidad.\n\nZeabur simplifica el proceso de configurar una base de datos. En lugar de administrar contenedores Docker o configurar servidores manualmente, puedes desplegar una instancia de MongoDB totalmente funcional desde el Marketplace con un solo clic.\n\n### Lo que aprenderás\n\nEn este tutorial, te guiaremos a través de:\n\n1. Desplegar un servicio de MongoDB en Zeabur.\n2. Conectarte a tu base de datos localmente usando **VS Code**, **Compass** o **Mongosh**.\n3. Configurar tu aplicación Node.js o Python para comunicarse con la base de datos.\n\n---\n\n## Fase 1: Desplegar la base de datos\n\n### Paso 1: Crear el servicio de MongoDB\n\nZeabur ofrece un \"despliegue con un clic\", lo que significa que rara vez necesitas configurar ajustes complejos manualmente.\n\n**Opción 1: Crear una instancia de Postgresql desde la página del proyecto**\n\n1. Inicia sesión en tu [**Zeabur Dashboard**](https://zeabur.com/).\n2. Haz clic en el botón **\"New Project\"**.\n3. Selecciona **\"Template\"** (Marketplace).\n4. Busca `MongoDB`.\n5. Selecciona la imagen oficial de MongoDB. Tu servicio comenzará a desplegarse inmediatamente.\n\n**Opción 2: Crear una instancia de MongoDB desde la página de la plantilla**\n\n1. Inicia sesión en tu [**Zeabur Dashboard**](https://zeabur.com/).\n2. Selecciona `Features` y `Template`.\n3. Elige o busca `MongoDB`.\n4. Selecciona **MongoDB** (normalmente la imagen oficial), haz clic en `deploy` y comenzará el despliegue.\n\n### Paso 2: Obtener tu cadena de conexión\n\n1. Ve a la pestaña **Instruction** del servicio.\n2. Copia la **cadena de conexión de MongoDB** (URI).\n    - Se ve así:\n    `mongodb://mongo:xxxx@xxx.clusters.zeabur.com:25909`\n\n---\n\n## Fase 2: Conectarse a la base de datos\n\n### Opción A: Conectar usando VS Code\n\nLa mejor forma de administrar MongoDB en VS Code es usando la extensión oficial.\n\n1. **Instalar la extensión:**\n    - Ve al Marketplace de extensiones.\n    - Busca **\"MongoDB for VS Code\"**.\n    - Instala la creada por **MongoDB**.\n2. **Agregar conexión:**\n    - Haz clic en el **icono de hoja de MongoDB** que aparece en la barra lateral.\n    - Haz clic en **\"Add Connection\"**.\n    - Selecciona **\"Connect with Connection String\"**.\n3. **Pegar y conectar:**\n    - Pega la URL que copiaste de Zeabur en el **Paso 3**.\n    - Presiona `Enter`.\n    - Ahora puedes navegar tus colecciones y documentos directamente en la barra lateral.\n\n---\n\n### Opción B: Conectar usando MongoDB Compass (GUI oficial)\n\nSi quieres visualizar tus datos (tablas, gráficas, análisis de esquema), **MongoDB Compass** es la herramienta estándar.\n\n1. Descarga e instala [MongoDB Compass](https://www.mongodb.com/products/tools/compass).\n2. Abre la aplicación.\n3. En el cuadro **\"URI\"**, pega la cadena de conexión de Zeabur.\n4. Haz clic en **\"Connect\"**.\n    - *Solución de problemas:* Si falla, asegúrate de no haber copiado accidentalmente el host \"Internal\". El host interno normalmente termina en `.svc.cluster.local`, lo cual no funcionará en tu computadora. El host público normalmente termina en `.zeabur.app`.\n\n---\n\n### Opción C: Conectar usando M**ongosh**\n\n[**mongosh**](https://www.mongodb.com/docs/mongodb-shell/) es un entorno REPL completo de JavaScript y Node.js para interactuar con bases de datos MongoDB.\n\nUna vez que lo hayas descargado e instalado según la documentación, vuelve a tu panel de Zeabur. Haz clic en la pestaña Connections del servicio de MongoDB y haz clic en el icono del ojo para copiar la cadena de conexión.\n![connect-path](https://cdn.zeabur.com/templates/mongodb/connect-path.png)\n\n```bash\nmongosh mongodb://<YOUR_CONNECT_PATH>\n\n```\n\nReemplaza **`<YOUR_CONNECT_PATH>`** con la cadena de conexión que acabas de copiar, y puedes usar el siguiente comando para probar si la conexión es exitosa:\n\n```bash\nuse mongodb_test\ndb.mongodb_test.insertOne({content: \"Hello World\"})\nshow dbs\n\n```\n\nSi tiene éxito, debería devolver:\n![mongosh-connect-success](https://cdn.zeabur.com/templates/mongodb/mongosh-connect-success.png)\n\nLuego podemos **`drop`** la base de datos de prueba.\n\n```bash\nuse mongodb_test\ndb.drop()\n```\n\n### \U0001F4A1 Nota importante: \"Internal\" vs \"Public\"\n\n- **Para desarrollo local:** Usa el dominio **Public** que acabas de configurar.\n- **Para tu app desplegada:** Cuando despliegues tu código backend (Node.js/Python) en Zeabur, cambia tu variable de entorno `MONGO_URI` para usar la cadena de conexión **Internal** (se encuentra en la sección \"Private\" de la pestaña Connection).\n    - **¿Por qué?** La conexión interna es mucho más rápida y no cuenta para tu uso de ancho de banda público."
    ja-JP:
        description: ソースコードが公開されている、クロスプラットフォームでドキュメント指向のデータベースプログラム。
        readme: "# MongoDB をデプロイする\n\n**MongoDB** は人気の高いオープンソースのドキュメント指向 NoSQL データベースです。従来の行と列ではなく、柔軟な JSON 風ドキュメントでデータを保存するため、高性能とスケーラビリティが求められるモダンな Web アプリに最適です。\n\nZeabur を使えば、Docker コンテナの管理やサーバー設定を手動で行う必要はありません。Marketplace からワンクリックで、すぐに利用可能な MongoDB をデプロイできます。\n\n### このチュートリアルで学べること\n\nこのチュートリアルでは、次の内容を案内します：\n\n1. Zeabur 上で MongoDB サービスをデプロイする\n2. **VS Code** / **Compass** / **Mongosh** を使ってローカルから接続する\n3. Node.js または Python アプリからデータベースへ接続する設定を行う\n\n---\n\n## フェーズ 1: データベースをデプロイする\n\n### ステップ 1: MongoDB サービスを作成する\n\nZeabur は「ワンクリックデプロイ」を提供しているため、複雑な設定を手動で行うことはほとんどありません。\n\n**オプション 1: Project ページから Postgresql インスタンスを作成する**\n\n1. [**Zeabur Dashboard**](https://zeabur.com/) にログインします。\n2. **\"New Project\"** ボタンをクリックします。\n3. **\"Template\"**（Marketplace）を選択します。\n4. `MongoDB` を検索します。\n5. 公式の MongoDB イメージを選択します。すぐにデプロイが開始されます。\n\n**オプション 2: テンプレートページから MongoDB インスタンスを作成する**\n\n1. [**Zeabur Dashboard**](https://zeabur.com/) にログインします。\n2. `Features` と `Template` を選択します。\n3. `MongoDB` を選択、または検索します。\n4. **MongoDB**（通常は公式イメージ）を選び、`deploy` をクリックするとデプロイが開始されます。\n\n### ステップ 2: 接続文字列を取得する\n\n1. サービスの **Instruction** タブに移動します。\n2. **MongoDB connection string**（URI）をコピーします。\n    - 例：\n    `mongodb://mongo:xxxx@xxx.clusters.zeabur.com:25909`\n\n---\n\n## フェーズ 2: データベースへ接続する\n\n### オプション A: VS Code で接続する\n\nVS Code で MongoDB を管理する最良の方法は、公式拡張機能を使うことです。\n\n1. **拡張機能をインストール:**\n    - 拡張機能 Marketplace を開きます。\n    - **\"MongoDB for VS Code\"** を検索します。\n    - **MongoDB** が提供している拡張機能をインストールします。\n2. **接続を追加:**\n    - サイドバーに表示される **MongoDB の葉アイコン** をクリックします。\n    - **\"Add Connection\"** をクリックします。\n    - **\"Connect with Connection String\"** を選択します。\n3. **貼り付けて接続:**\n    - Zeabur からコピーした URL を **Step 3** に貼り付けます。\n    - `Enter` を押します。\n    - サイドバーからコレクションやドキュメントを参照できるようになります。\n\n---\n\n### オプション B: MongoDB Compass（公式 GUI）で接続する\n\nデータの可視化（テーブル、グラフ、スキーマ分析など）をしたい場合、**MongoDB Compass** は標準的なツールです。\n\n1. [MongoDB Compass](https://www.mongodb.com/products/tools/compass) をダウンロードしてインストールします。\n2. アプリを開きます。\n3. **\"URI\"** 欄に Zeabur の接続文字列を貼り付けます。\n4. **\"Connect\"** をクリックします。\n    - *トラブルシューティング:* 失敗する場合は、\"Internal\" ホストを誤ってコピーしていないか確認してください。Internal は通常 `.svc.cluster.local` で終わり、PC からは接続できません。Public は通常 `.zeabur.app` で終わります。\n\n---\n\n### オプション C: M**ongosh** で接続する\n\n[**mongosh**](https://www.mongodb.com/docs/mongodb-shell/) は、MongoDB データベースとやり取りするための完全な機能を備えた JavaScript / Node.js REPL 環境です。\n\nドキュメントに従ってダウンロードしてインストールしたら、Zeabur ダッシュボードに戻ります。MongoDB サービスの Connections タブを開き、目のアイコンをクリックして接続文字列をコピーします。\n![connect-path](https://cdn.zeabur.com/templates/mongodb/connect-path.png)\n\n```bash\nmongosh mongodb://<YOUR_CONNECT_PATH>\n\n```\n\n**`<YOUR_CONNECT_PATH>`** を先ほどコピーした接続文字列に置き換え、次のコマンドで接続をテストできます：\n\n```bash\nuse mongodb_test\ndb.mongodb_test.insertOne({content: \"Hello World\"})\nshow dbs\n\n```\n\n成功すると、次のような結果が返されます：\n![mongosh-connect-success](https://cdn.zeabur.com/templates/mongodb/mongosh-connect-success.png)\n\nその後、テストデータベースを **`drop`** できます。\n\n```bash\nuse mongodb_test\ndb.drop()\n```\n\n### \U0001F4A1 重要: \"Internal\" と \"Public\" の違い\n\n- **ローカル開発:** 先ほど設定した **Public** ドメインを使用します。\n- **デプロイ済みアプリ:** バックエンド（Node.js/Python）を Zeabur にデプロイする場合は、`MONGO_URI` 環境変数を **Internal** 接続文字列（Connection タブの \"Private\" セクション）に切り替えます。\n    - **理由:** Internal 接続は高速で、Public の帯域使用量としてカウントされません。\n"
    zh-CN:
        description: 一个开源、跨平台、面向文档的数据库程序。
        readme: "# 部署 MongoDB\n\n**MongoDB** 是一款流行的开源、面向文档的 NoSQL 数据库。它不使用传统的行和列，而是用灵活的类 JSON 文档来存储数据，非常适合需要高性能与可扩展性的现代 Web 应用。\n\nZeabur 让数据库部署变得简单。你无需手动管理 Docker 容器或配置服务器，只要在 Marketplace 一键即可部署一个可用的 MongoDB 实例。\n\n### 你将学到什么\n\n在本教程中，我们将带你完成：\n\n1. 在 Zeabur 上部署 MongoDB 服务。\n2. 使用 **VS Code**、**Compass** 或 **Mongosh** 在本地连接数据库。\n3. 配置你的 Node.js 或 Python 应用与数据库通信。\n\n---\n\n## 阶段 1：部署数据库\n\n### 步骤 1：创建 MongoDB 服务\n\nZeabur 提供“一键部署”，你通常不需要手动配置复杂的设置。\n\n**选项 1：从 Project 页面创建 Postgresql 实例**\n\n1. 登录你的 [**Zeabur Dashboard**](https://zeabur.com/)。\n2. 点击 **\"New Project\"** 按钮。\n3. 选择 **\"Template\"**（Marketplace）。\n4. 搜索 `MongoDB`。\n5. 选择官方 MongoDB 镜像，服务将立即开始部署。\n\n**选项 2：从模板页面创建 MongoDB 实例**\n\n1. 登录你的 [**Zeabur Dashboard**](https://zeabur.com/)。\n2. 选择 `Features` 和 `Template`。\n3. 选择或搜索 `MongoDB`。\n4. 选择 **MongoDB**（通常是官方镜像），点击 `deploy` 即可开始部署。\n\n### 步骤 2：获取连接字符串\n\n1. 进入服务的 **Instruction** 标签页。\n2. 复制 **MongoDB connection string**（URI）。\n    - 形如：\n    `mongodb://mongo:xxxx@xxx.clusters.zeabur.com:25909`\n\n---\n\n## 阶段 2：连接数据库\n\n### 选项 A：使用 VS Code 连接\n\n在 VS Code 中管理 MongoDB 的最佳方式是使用官方扩展。\n\n1. **安装扩展：**\n    - 打开扩展市场（Extensions Marketplace）。\n    - 搜索 **\"MongoDB for VS Code\"**。\n    - 安装由 **MongoDB** 发布的扩展。\n2. **添加连接：**\n    - 点击侧边栏出现的 **MongoDB 叶子图标**。\n    - 点击 **\"Add Connection\"**。\n    - 选择 **\"Connect with Connection String\"**。\n3. **粘贴并连接：**\n    - 将你在 Zeabur 中复制的 URL 粘贴到 **Step 3**。\n    - 按下 `Enter`。\n    - 现在你可以在侧边栏直接浏览 Collections 与 Documents。\n\n---\n\n### 选项 B：使用 MongoDB Compass（官方 GUI）连接\n\n如果你想可视化数据（表格、图表、Schema 分析），**MongoDB Compass** 是标准工具。\n\n1. 下载并安装 [MongoDB Compass](https://www.mongodb.com/products/tools/compass)。\n2. 打开应用。\n3. 在 **\"URI\"** 输入框中粘贴 Zeabur 的连接字符串。\n4. 点击 **\"Connect\"**。\n    - *排错提示:* 如果连接失败，请确认你没有误复制 \"Internal\" 主机。内部主机通常以 `.svc.cluster.local` 结尾，无法在你的电脑上使用。公网主机通常以 `.zeabur.app` 结尾。\n\n---\n\n### 选项 C：使用 M**ongosh** 连接\n\n[**mongosh**](https://www.mongodb.com/docs/mongodb-shell/) 是一个功能完整的 JavaScript 和 Node.js REPL 环境，用于与 MongoDB 数据库交互。\n\n按照文档下载并安装后，回到你的 Zeabur Dashboard。在 MongoDB 服务的 Connections 标签页中，点击眼睛图标复制连接字符串。\n![connect-path](https://cdn.zeabur.com/templates/mongodb/connect-path.png)\n\n```bash\nmongosh mongodb://<YOUR_CONNECT_PATH>\n\n```\n\n将 **`<YOUR_CONNECT_PATH>`** 替换为你刚刚复制的连接字符串，然后执行以下命令测试是否连接成功：\n\n```bash\nuse mongodb_test\ndb.mongodb_test.insertOne({content: \"Hello World\"})\nshow dbs\n\n```\n\n如果成功，会返回：\n![mongosh-connect-success](https://cdn.zeabur.com/templates/mongodb/mongosh-connect-success.png)\n\n然后我们可以 **`drop`** 测试数据库。\n\n```bash\nuse mongodb_test\ndb.drop()\n```\n\n### \U0001F4A1 重要提示：\"Internal\" vs \"Public\"\n\n- **本地开发：** 使用你刚设置好的 **Public** 域名。\n- **部署到 Zeabur 的应用：** 当你把后端代码（Node.js/Python）部署到 Zeabur 后，将 `MONGO_URI` 环境变量切换为 **Internal** 连接字符串（可在 Connection 标签页的 \"Private\" 部分找到）。\n    - **为什么？** 内网连接更快，并且不会计入公网带宽用量。\n"
    zh-TW:
        description: 一個開源、跨平台、面向文件的資料庫程式。
        readme: "# 部署 MongoDB\n\n**MongoDB** 是一款受歡迎的開源、面向文件的 NoSQL 資料庫。它不使用傳統的列與欄，而是以彈性的類 JSON 文件儲存資料，非常適合需要高效能與可擴展性的現代 Web 應用。\n\nZeabur 讓資料庫部署變得更簡單。你不需要手動管理 Docker 容器或設定伺服器，只要在 Marketplace 一鍵即可部署可用的 MongoDB 實例。\n\n### 你將學到什麼\n\n在本教學中，我們將帶你完成：\n\n1. 在 Zeabur 上部署 MongoDB 服務。\n2. 使用 **VS Code**、**Compass** 或 **Mongosh** 在本機連線資料庫。\n3. 設定你的 Node.js 或 Python 應用與資料庫溝通。\n\n---\n\n## 階段 1：部署資料庫\n\n### 步驟 1：建立 MongoDB 服務\n\nZeabur 提供「一鍵部署」，通常你不需要手動設定複雜的選項。\n\n**選項 1：從 Project 頁面建立 Postgresql 實例**\n\n1. 登入你的 [**Zeabur Dashboard**](https://zeabur.com/)。\n2. 點擊 **\"New Project\"** 按鈕。\n3. 選擇 **\"Template\"**（Marketplace）。\n4. 搜尋 `MongoDB`。\n5. 選擇官方 MongoDB 映像，服務會立刻開始部署。\n\n**選項 2：從模板頁面建立 MongoDB 實例**\n\n1. 登入你的 [**Zeabur Dashboard**](https://zeabur.com/)。\n2. 選擇 `Features` 與 `Template`。\n3. 選擇或搜尋 `MongoDB`。\n4. 選擇 **MongoDB**（通常為官方映像），點擊 `deploy` 即可開始部署。\n\n### 步驟 2：取得連線字串\n\n1. 前往服務的 **Instruction** 分頁。\n2. 複製 **MongoDB connection string**（URI）。\n    - 看起來像這樣：\n    `mongodb://mongo:xxxx@xxx.clusters.zeabur.com:25909`\n\n---\n\n## 階段 2：連線資料庫\n\n### 選項 A：使用 VS Code 連線\n\n在 VS Code 管理 MongoDB 的最佳方式是使用官方擴充套件。\n\n1. **安裝擴充套件：**\n    - 前往 Extensions Marketplace。\n    - 搜尋 **\"MongoDB for VS Code\"**。\n    - 安裝由 **MongoDB** 發布的套件。\n2. **新增連線：**\n    - 點擊側邊欄出現的 **MongoDB 葉子圖示**。\n    - 點擊 **\"Add Connection\"**。\n    - 選擇 **\"Connect with Connection String\"**。\n3. **貼上並連線：**\n    - 將你在 Zeabur 複製的 URL 貼到 **Step 3**。\n    - 按下 `Enter`。\n    - 現在你可以在側邊欄直接瀏覽 Collections 與 Documents。\n\n---\n\n### 選項 B：使用 MongoDB Compass（官方 GUI）連線\n\n若你想要視覺化你的資料（表格、圖表、Schema 分析），**MongoDB Compass** 是標準工具。\n\n1. 下載並安裝 [MongoDB Compass](https://www.mongodb.com/products/tools/compass)。\n2. 開啟應用程式。\n3. 在 **\"URI\"** 輸入框貼上 Zeabur 的連線字串。\n4. 點擊 **\"Connect\"**。\n    - *疑難排解：* 若失敗，請確認你沒有誤複製到 \"Internal\" 主機。內部主機通常以 `.svc.cluster.local` 結尾，無法在你的電腦上使用；而公網主機通常以 `.zeabur.app` 結尾。\n\n---\n\n### 選項 C：使用 M**ongosh** 連線\n\n[**mongosh**](https://www.mongodb.com/docs/mongodb-shell/) 是一個功能完整的 JavaScript 與 Node.js REPL 環境，可用來與 MongoDB 資料庫互動。\n\n依照文件下載並安裝後，回到你的 Zeabur Dashboard。在 MongoDB 服務的 Connections 分頁中點擊眼睛圖示以複製連線字串。\n![connect-path](https://cdn.zeabur.com/templates/mongodb/connect-path.png)\n\n```bash\nmongosh mongodb://<YOUR_CONNECT_PATH>\n\n```\n\n將 **`<YOUR_CONNECT_PATH>`** 替換為你剛剛複製的連線字串，並使用以下指令測試是否連線成功：\n\n```bash\nuse mongodb_test\ndb.mongodb_test.insertOne({content: \"Hello World\"})\nshow dbs\n\n```\n\n若成功，會回傳：\n![mongosh-connect-success](https://cdn.zeabur.com/templates/mongodb/mongosh-connect-success.png)\n\n然後我們可以 **`drop`** 測試資料庫。\n\n```bash\nuse mongodb_test\ndb.drop()\n```\n\n### \U0001F4A1 重要提示：\"Internal\" vs \"Public\"\n\n- **本機開發：** 使用你剛設定好的 **Public** 網域。\n- **部署的應用：** 當你把後端程式（Node.js/Python）部署到 Zeabur 後，請將 `MONGO_URI` 環境變數改成 **Internal** 連線字串（可在 Connection 分頁的 \"Private\" 區塊找到）。\n    - **為什麼？** 內網連線更快，且不會計入公網頻寬用量。"
