Using Cloud Firestore in Datastore Mode Stay organized with collections Save and categorize content based on your preferences.
Firestore is a NoSQL document database built for automatic scaling,high performance, and ease of application development. It is the newest versionof Datastore and introduces several improvements overDatastore.
BecauseFirestore in Datastore mode (Datastore) is optimized forserver use cases and for App Engine, we recommend usingDatastore mode for databases that will be used primarily byApp Engine apps. Firestore in Native mode is most useful formobile and real-time notification use cases. For more information aboutFirestore modes, seeChoosing between Native Mode andDatastore mode.
Using Datastore mode with App Engine
To use Datastore mode with App Engine:
If you haven't already done so,create a databaseand choose Firestore in Datastore mode.
You can use existing Datastore databases with App Engineapps. These existing databaseswill be automatically upgraded toFirestore in Datastoremode.
If you have a new Python 3 apps, you should use theDatastore mode client libraryto interact with Datastore mode:
In your app, declare Datastore as a dependency by adding
google-cloud-datastoreto your app'srequirements.txtfile. Learn moreabout specifying dependencies.Use the Google Cloud Client Library toread and write entitiesand toquery data.
If you are planning to upgrade your Python 2 app to Python 3, Google recommendsporting your Python 2 app that usesApp Engine NDBto Python 3, andthenmigrating to Cloud NDB.To learn how to access App Engine NDB in Python 3, see theAccessing App Engine legacy bundled services for Python 3.
For additional resources plus an example of migrating from a Python 2
webappapp using App Engine NDB to an equivalent Python 3 Flask app withApp Engine NDB enabled, see thebundled services for Python3.
Configuring indexes
Datastore mode usesindexesfor every query your application makes. The indexes are updated whenever anentity changes, so the results can be returned quickly when the app makes aquery.
Datastore mode automatically creates single-property indexes for use withsimple types of queries. For complex queries that include multiple properties,you'll need to configure composite indexes in your app's
index.yamlfile.The App Engine development server will update your
index.yamlfilewith the composite indexes needed to run your tests. Similarly, theDatastore mode emulator can generate indexeswhen you run tests.You can also add the indexes to your app's
index.yamlfilemanuallyif you do not run local tests or your tests do not include complex queries.Setting database permissions
By default, your app has all the permissions required to read and write toDatastore mode and Firestore databases in yourGoogle Cloud project.
To manage these permissions, each App Engine app uses adefault serviceaccountthat gives full read and write access to Datastore modeand Firestore databases in the same project as the app. You canchange the permissions of the default serviceaccount,but your app may lose access unless you assign an IAM role with therequired permissions.
For information about allowing other users, apps, or projects to access a database, seeAccessing your database.
Using the Datastore mode emulator for local testing
The Google Cloud CLI includes a localemulator of the production Datastore modemode environment.You can use the emulator to develop and test your application locally. Inaddition, the emulator can help you generate indexes for your productionDatastore mode mode instance and delete unneeded indexes.
If you use the App Enginelocal developmentserver to test yourapp, you can ensure that the server will use the Datastore modeemulator by setting the
--support_datastore_emulator=trueflag when startingthe server.If you are using the Datastore mode emulator, dev_appserver will display:
... Using Cloud Datastore Emulator.Pricing, quotas, and limits
Datastore mode offers a free quota with daily limits. Paidaccounts offer unlimited storage, read, and write operations. More informationis available on theDatastore Quotas page.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.