Java 8 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Java 8 アプリケーションをデプロイできなくなります。既存の Java 8 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Java に移行することをおすすめします。
Cloud Firestore の Datastore モードでの使用
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Firestore は、自動スケーリングと高性能を実現し、アプリケーション開発を簡素化するように構築された NoSQL ドキュメント データベースです。これは Datastore の最新バージョンで、Datastore のいくつかの点が改善されています。
Datastore モードの Firestore は、サーバーのユースケースと App Engine 用に最適化されているため、主に App Engine アプリで使用されるデータベースには Firestore を Datastore モードで使用することをおすすめします。ネイティブ モードの Firestore は、モバイルとリアルタイムの通知のユースケースに最適です。Firestore モードの詳細については、ネイティブ モードと Datastore モードからの選択をご覧ください。
App Engine での Datastore モードの使用
App Engine で Datastore モードを使用するには:
まだ作成していない場合は、データベースを作成し、Datastore モードの Firestore を選択します。
既存の Datastore データベースは、App Engine アプリで使用できます。その場合、既存の Cloud Datastore データベースは Datastore モードの Firestore に自動的にアップグレードされます。
ライブラリをアプリの依存関係ファイルに追加して、アプリ内で Datastore を依存関係として宣言します。
Google Cloud クライアント ライブラリを使用して、エンティティの読み取り / 書き込みとデータのクエリを行います。
インデックスの構成
Datastore モードでは、アプリケーションが作成するすべてのクエリに対してインデックスを使用します。インデックスはエンティティが変更されるたびに更新されるので、アプリからのクエリに対してすばやく結果を返すことができます。
Datastore モードでは、単純な種類のクエリで使用する単一プロパティのインデックスを自動的に作成します。複数のプロパティを含む複雑なクエリについては、アプリの index.yaml
ファイル内に複合インデックスを構成する必要があります。
App Engine 開発用サーバーは、テストを実行するために必要な複合インデックスを使用して index.yaml
ファイルを更新します。同様に、テストを実行する際は Datastore モード エミュレータでインデックスを生成できます。
ローカルテストを実行しない場合や、テストに複雑なクエリが含まれていない場合は、アプリの index.yaml
ファイルに手動でインデックスを追加することもできます。
データベース権限の設定
デフォルトでは、Google Cloud プロジェクト内の Datastore モードと Firestore データベースに対して読み取り / 書き込みを行うために必要なすべての権限がアプリに付与されます。
これらの権限を管理するために、App Engine アプリのそれぞれがデフォルトのサービス アカウントを使用します。デフォルトのサービス アカウントにより、アプリには同じプロジェクト内にある Datastore モードと Firestore データベースに対して読み取りと書き込みを行うための完全アクセス権が与えられます。デフォルトのサービス アカウントの権限を変更することはできますが、必要な権限を IAM ロールに割り当てなければ、アプリがデータベースにアクセスできなくなる可能性があります。
他のユーザー、アプリ、プロジェクトにデータベースへのアクセスを許可する方法については、データベースへのアクセスをご覧ください。
ローカルテストでの Datastore モード エミュレータの使用
Google Cloud CLI for Java には、ローカルの開発用サーバーが含まれています。このサーバーを使用すると、手元にあるマシン上でアプリケーションをテストできます。ローカルの開発用サーバーは、App Engine の Java Runtime Environment や Datastore モードなどのすべてのサービスをエミュレートします。
開発用サーバーは、テスト中にアプリケーションが実行するクエリに基づいて、そのアプリケーションに必要な Datastore モードのインデックス構成を生成します。
料金、割り当て、制限
Datastore モードでは、一定の割り当て量を無料で使用できます(1 日の使用量に上限があります)。有料アカウントの場合には、保存、読み取り、書き込みオペレーションを無制限で行うことができます。詳細については、データストアの割り当てをご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eFirestore is a NoSQL document database designed for automatic scaling, high performance, and ease of development, with improvements over its predecessor, Datastore.\u003c/p\u003e\n"],["\u003cp\u003eFirestore offers two modes: Datastore mode, which is optimized for server use cases and App Engine, and Native mode, which is designed for mobile and real-time notifications.\u003c/p\u003e\n"],["\u003cp\u003eDatastore mode utilizes indexes for each query, automatically generating single-property indexes and requiring composite indexes for complex queries, which can be managed via the \u003ccode\u003eindex.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine apps using Datastore mode have default permissions to read and write to the database, managed by a service account, but these permissions can be modified, though it could cause access issues if the proper role isn't assigned.\u003c/p\u003e\n"],["\u003cp\u003eDatastore mode offers a free quota with daily limits, with paid accounts providing unlimited storage and read/write operations.\u003c/p\u003e\n"]]],[],null,["# Using Cloud Firestore in Datastore Mode\n\nFirestore is a NoSQL document database built for automatic scaling,\nhigh performance, and ease of application development. It is the newest version\nof Datastore and introduces several improvements over\nDatastore.\n\nBecause Firestore in [Datastore mode](/datastore/docs)\nis optimized for server use cases and for\nApp Engine, we recommend using Firestore in\nDatastore mode for databases that will be used primarily by\nApp Engine apps. Firestore in Native mode is most useful for\nmobile and real-time notification use cases. For more information about\nFirestore modes, see [Choosing between Native Mode and\nDatastore mode](/datastore/docs/firestore-or-datastore).\n\nUsing Datastore mode with App Engine\n------------------------------------\n\nTo use Datastore mode with App Engine:\n\n1. If you haven't already done so,\n [create a database](/datastore/docs/store-query-data#create_a_database)\n and choose Firestore in Datastore mode.\n\n You can use existing Datastore databases with App Engine\n apps. These existing databases [will be automatically upgraded to\n Firestore in Datastore\n mode](/datastore/docs/upgrade-to-firestore).\n\n\n 1. In your app, declare Datastore as a dependency\n\n by [adding the library to your app's dependencies\n file](/datastore/docs/reference/libraries#client-libraries-install-java).\n\n \u003cbr /\u003e\n\n 2. Use the Google Cloud Client Library to\n [read and write entities](/datastore/docs/concepts/entities)\n and to [query data](/datastore/docs/concepts/queries).\n\n Configuring indexes\n -------------------\n\n Datastore mode uses\n [indexes](/datastore/docs/concepts/indexes)\n for every query your application makes. The indexes are updated whenever an\n entity changes, so the results can be returned quickly when the app makes a\n query.\n\n Datastore mode automatically creates single-property indexes for use with\n simple types of queries. For complex queries that include multiple properties,\n you'll need to configure composite indexes in your app's `index.yaml` file.\n\n The App Engine development server will update your `index.yaml` file\n with the composite indexes needed to run your tests. Similarly, the\n [Datastore mode emulator can generate indexes](/datastore/docs/tools)\n when you run tests.\n\n You can also add the indexes to your app's\n `index.yaml` file [manually](/appengine/docs/legacy/standard/java/configuring-datastore-indexes-with-index-yaml) if you do not run local\n tests or your tests do not include complex queries.\n\n Setting database permissions\n ----------------------------\n\n By default, your app has all the permissions required to read and write to\n Datastore mode and Firestore databases in your\n Google Cloud project.\n\n To manage these permissions, each App Engine app uses a [default service\n account](/appengine/docs/legacy/standard/java/service-account)\n that gives full read and write access to Datastore mode\n and Firestore databases in the same project as the app. You can\n [change the permissions of the default service\n account](/appengine/docs/legacy/standard/java/access-control#modify-service-account),\n but your app may lose access unless you assign an IAM role with the\n [required permissions](/datastore/docs/access/iam#required_permissions).\n\n For information about allowing other users, apps, or projects to access a database, see\n [Accessing your database](/datastore/docs/activate).\n\n Using the Datastore mode emulator for local testing\n ---------------------------------------------------\n\n The Google Cloud CLI for Java includes a [local development\n server](/appengine/docs/legacy/standard/java/tools/using-local-server) for testing your application on your computer. The local development server emulates the App Engine Java runtime environment and all of its services, including Datastore mode.\n\n \u003cbr /\u003e\n\n The development server generates configuration for Datastore mode\n indexes needed by your application, determined from the queries it performs\n while you are testing it.\n\n Pricing, quotas, and limits\n ---------------------------\n\n Datastore mode offers a free quota with daily limits. Paid\n accounts offer unlimited storage, read, and write operations. More information\n is available on the [Datastore Quotas](/appengine/docs/legacy/standard/java/quotas#Datastore) page."]]