firebase/firebase-firestore-enterprise-native-mode

Firestore Enterprise ネイティブモードの包括的なガイド(プロビジョニング、データモデル、セキュリティルール、SDK の使用を含む)。ユーザーが Firestore Enterprise をネイティブモードでセットアップする際や、セキュリティルールの作成、アプリケーションでの Firestore SDK の使用について支援が必要な場合に、このスキルを使用します。

firebase-firestore-enterprise-native-mode とは?

Firestore Enterprise ネイティブモードは、Google Cloud Firestore をエンタープライズ向けに構成するためのスキルです。このスキルは、Firestore データベースのプロビジョニング(インスタンスの作成、リージョン設定、容量計画など)、データモデルの設計(コレクション、ドキュメント、サブコレクションの構造化)、セキュリティルールの記述(IAM ベースのアクセス制御、条件付きルール、フィールドレベルの制限)、および Firestore SDK(Node.js、Python、Go、Java など)を使用したデータの読み書きやリアルタイムリスナーの実装方法を網羅しています。このスキルは、Firebase コンソールや gcloud CLI を介した管理操作から、アプリケーションコード内での Firestore 操作まで、エンタープライズ要件に対応するための実践的なガイドを提供します。開発者や DevOps エンジニアが、高可用性と厳格なセキュリティを備えた Firestore 環境を迅速に構築し、運用するのに役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/firebase/agent-skills/tree/main/skills/firebase-firestore-enterprise-native-mode

Installed? Explore more 生産性&コラボレーション skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

firebase-firestore-enterprise-native-mode は何をしますか?

Firestore Enterprise ネイティブモードの包括的なガイドです。プロビジョニング、データモデル、セキュリティルール、SDK の使用について説明します。ユーザーが Firestore Enterprise をネイティブモードでセットアップする際や、セキュリティルールの作成、アプリケーションでの Firestore SDK の使用について支援が必要な場合に、このスキルを使用します。

概要

このスキルは、Firestore Enterprise をネイティブモードで構成および使用するための手順を提供します。対象読者は、Firebase または Google Cloud Platform を使用する開発者および管理者です。

前提条件

  • Google Cloud プロジェクトがアクティブであること。
  • Firebase プロジェクトが GCP プロジェクトにリンクされていること。
  • Firestore Enterprise の有効なサブスクリプション(従量課金制または定額制)。

プロビジョニング

  1. Firestore データベースの作成

    • Firebase コンソールまたは gcloud CLI を使用して、Firestore Enterprise インスタンスをネイティブモードでプロビジョニングします。
    • 例: Firebase コンソールで「データベースを作成」を選択し、「ネイティブモード」を選択します。
  2. リージョンの選択

    • データの常駐要件に基づいて GCP リージョンを選択します(例: us-central1、europe-west1)。
    • 選択後は変更できないため、注意してください。
  3. 容量の計画

    • 必要なストレージと読み取り/書き込み容量を見積もります。Firestore Enterprise では自動スケーリングがサポートされています。

データモデル

Firestore は NoSQL ドキュメントデータベースです。データは次の構造で整理されます。

  • コレクション: ドキュメントのコンテナ(例: users、orders)。
  • ドキュメント: キーと値のペアのセット。各ドキュメントには一意の ID があります。
  • サブコレクション: ドキュメント内のコレクション(深い階層を避けるために推奨)。

例

{
  "users": {
    "user123": {
      "name": "Alice",
      "email": "[email protected]",
      "createdAt": "2025-01-01T00:00:00Z"
    }
  }
}

セキュリティルール

Firestore のセキュリティルールは、データベースへのアクセスを制御します。エンタープライズ環境では、最小権限の原則に従ってルールを設定します。

基本ルール

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // 認証済みユーザーのみアクセスを許可
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

条件付きルール(顧客データへのアクセス制限)

match /users/{userId} {
  allow read: if request.auth.uid == userId;
  allow write: if request.auth.uid == userId && request.resource.data.email.matches(".*@example.com$");
}

SDK の使用

Firestore は複数の言語で SDK を提供しています。以下は主要な SDK の使用例です。

Node.js

const { Firestore } = require('@google-cloud/firestore');

// データベースの初期化
const db = new Firestore();

// ドキュメントの読み込み
async function getUser(userId) {
  const doc = await db.collection('users').doc(userId).get();
  if (!doc.exists) {
    console.log('ドキュメントが見つかりません');
    return null;
  }
  return doc.data();
}

Python

from google.cloud import firestore

db = firestore.Client()

# ユーザードキュメントの追加
def add_user(user_id, data):
    doc_ref = db.collection('users').document(user_id)
    doc_ref.set(data)
    print(f'ユーザー {user_id} を追加しました')

リアルタイムリスナー

// Node.js でのリアルタイム更新
const unsubscribe = db.collection('users')
  .where('status', '==', 'active')
  .onSnapshot((snapshot) => {
    snapshot.forEach((doc) => {
      console.log(doc.id, '=>', doc.data());
    });
  });

ベストプラクティス

  • インデックス: クエリのパフォーマンスを向上させるために、複合インデックスを作成します。
  • バッチ操作: 複数の書き込みを batch() でグループ化し、アトミックに実行します。
  • トランザクション: 競合状態を避けるために、重要な操作にはトランザクションを使用します。

トラブルシューティング

  • 権限エラー: セキュリティルールが正しく設定されているか確認します。
  • 制限の超過: Firestore の制限(1 秒あたりの書き込み数など)を超えていないか確認します。
  • 接続の問題: ファイアウォールやネットワーク設定を確認します。

参考リンク

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

firebase/developing-genkit-dart

Generates code and provides documentation for the Genkit Dart SDK. Use when the user asks to build AI agents in Dart, use Genkit flows, or integrate LLMs into Dart/Flutter applications.

firebase/developing-genkit-go

Develop AI-powered applications using Genkit in Go. Use when the user asks to build AI features, agents, flows, or tools in Go using Genkit, or when working with Genkit Go code involving generation, prompts, streaming, tool calling, or model providers.

firebase/developing-genkit-js

Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.

firebase/developing-genkit-python

Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.

firebase/firebase-ai-logic

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

firebase/firebase-ai-logic-basics

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

firebase/firebase-app-hosting-basics

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

firebase/firebase-auth-basics

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

firebase/firebase-basics

Provides foundational setup, authentication, and project management workflows for Firebase using the Firebase CLI. Use when checking Firebase CLI version (must use 'npx -y firebase-tools@latest --version'), initializing a Firebase environment, authenticating, setting active projects, or setting up `google-services.json` or `GoogleService-Info.plist` files.

firebase/firebase-crashlytics

Comprehensive guide for Firebase Crashlytics, including provisioning and SDK usage. Use this skill when the user needs help setting up Crashlytics, adding crash reporting, or using the Crashlytics SDK in their application.

firebase/firebase-data-connect

Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational database with Firebase, or when the user mentions SQL Connect or Data Connect.

firebase/firebase-firestore

Sets up, manages, and executes queries against Cloud Firestore database instances, including advanced native full-text search and relational joins using pipelines. You MUST unconditionally activate this skill if you plan to use Firestore in any way. Use when listing or creating Firestore databases, configuring security rules, designing data models, writing client SDK queries (including search/joins), or checking indexes.

firebase/firebase-firestore-basics

Comprehensive guide for Firestore basics including provisioning, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore, writing security rules, or using the Firestore SDK in their application.

firebase/firebase-firestore-standard

Comprehensive guide for Firestore Standard Edition, including provisioning, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore, writing security rules, or using the Firestore SDK in their application.

firebase/firebase-hosting-basics

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

firebase/firebase-local-env-setup

Bare minimum INITIAL setup for getting started with Firebase (Node.js, CLI installation, first-time login). Use ONLY for first-time setup. For updating, troubleshooting, or refreshing an existing environment, use the firebase-basics skill instead.

firebase/firebase-remote-config-basics

Comprehensive guide for Firebase Remote Config, including template management and SDK usage. Use this skill when the user needs help setting up Remote Config, managing feature flags, or updating app behavior dynamically.

firebase/firebase-security-rules-auditor

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

firebase/firestore-security-rules-auditor

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

firebase/xcode-project-setup

Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).

関連スキル