We’re excited to announce support for multiple Firestore databases in a Google Cloud project. You can now create multiple databases in a project to isolate customer data, microservices, or dev/test/staging environments.
The multiple databases feature includes support for the following:
Firestore database CRUD management: Firestore now exposes a new API endpoint, Terraform resource, gcloud CLI command and Firebase CLI command to manage the lifecycle of one or more Firestore databases.
Support for both Firestore database modes: You can create new databases, in the same project, in either Firestore Native Mode or Datastore Mode.
Support for all Firestore regions: You can create new databases, in the same project, in any supported Firestore region.
Billing: You can now track the cost of your databases separately through Cloud Billing and BigQuery. This makes it easier to both observe consumption and budget for each databases’ usage.
Cloud Monitoring: Firestore’s Cloud Monitoring Metrics and Stats are now aggregated at the database-level.
Sound like a good candidate for your application? Let’s take an end-to-end example to see how it works.
To create a Firestore database, you need to specify a database identifier, mode, and location. There are multiple ways to create a Firestore database. Here is an example of how to create a Firestore native database named reviews in the us-west1 location using the gcloud CLI:
Once your database is created, you can access it using the Firestore/Datastore console.
When you no longer need a Firestore database, you can delete the Firestore database by running.
That’s everything you need to do. Once a database is deleted, Firestore performs the data deletion on your behalf.
When using the Firestore client libraries with your newly created databases, specify the database name to get the appropriate Firestore database instance. If you don’t specify a database name, the client library falls back to the (default) database. Here’s an example for writing to a database named “test” with the Firebase Admin SDK for Java:
Cloud BlogRead More