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

Data 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


Reactive Repository


Declarative Transaction


REST Repository

Query methods

Query annotation





Add the Spring Data Firestore starter:

compile group: '', name: 'spring-cloud-gcp-starter-data-firestore'


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.

Notice that there is no explicit configuration for username/password. Cloud Firestore authentication uses the GCP credential (either your user credential, or Service Account credential), and authorization is configured via Identity Access Management (IAM).


Spring Data Cloud Firestore allows you to map domain POJOs to Datastore documents via annotations.

class Order {
private String id;
private String description;
private LocalDateTime timestamp;
private List<OrderItem> items;
// Getters and setters ...
class OrderItem {
private String description;
private Long quantity;
// Getters and setters ...

Because Firestore is a document-oriented NoSQL database, you can have nested structure and can establish parent-children relationships without complicated foreign keys.


Use Spring Data Reactive repository to quickly get CRUD access to the Cloud Firestore.

interface OrderRepository extends FirestoreReactiveRepository<Order> {

In a business logic service, you can utilize the repositories:

class OrderService {
private final OrderRepository orderRepository;
OrderService(OrderRepository orderRepository) {
this.orderRepository = orderRepository;
Mono<Order> createOrder(Order order) {
// Set the creation time
order.setTimestamp(Timestamp.of(new Date()));
// Children are saved in cascade.