Native Mode
Cloud Firestore Native Instance
There can only be one Datastore instance associated with a single project. The Cloud Firestore in Datastore instance is automatically created when you enable the API:
Enable API
gcloud services enable firestore.googleapis.comData Schema
Because Cloud Firestore is a NoSQL database, you do not need to explicitly create tables, define data schema, etc. Simply use the API to store new documents, and perform CRUD operations.
Spring Data Firestore
The easiest way to access Cloud Firestore is using Spring Cloud GCP's Spring Data Firestore starter. This starter provides full Spring Data support for Cloud Firestore while implementing idiomatic access patterns.
Spring Data Feature
Supported
Reactive Repository
✅
ORM
✅
Declarative Transaction
✅
Repository
✅
REST Repository
❌
Query methods
✅
Query annotation
✅
Pagination
✅
Events
✅
Auditing
✅
Dependency
Add the Spring Data Firestore starter:
Configuration
There is no explicit configuration required if you use the automatic authentication and project ID detection. I.e., if you already logged in locally with gcloud command line, then it'll automatically use Datastore from the project you configured in gcloud.
ORM
Spring Data Cloud Firestore allows you to map domain POJOs to Datastore documents via annotations.
Because Firestore is a document-oriented NoSQL database, you can have nested structure and can establish parent-children relationships without complicated foreign keys.
Repository
Use Spring Data Reactive repository to quickly get CRUD access to the Cloud Firestore.
In a business logic service, you can utilize the repositories:
Samples
Last updated
Was this helpful?