public class FirestoreTemplate extends Object implements FirestoreReactiveOperations
FirestoreReactiveOperations.| Constructor and Description |
|---|
FirestoreTemplate(com.google.firestore.v1.FirestoreGrpc.FirestoreStub firestore,
String parent,
FirestoreClassMapper classMapper,
FirestoreMappingContext mappingContext)
Constructor for FirestoreTemplate.
|
| Modifier and Type | Method and Description |
|---|---|
<T> reactor.core.publisher.Mono<Long> |
count(Class<T> entityClass)
Count entities of the given domain.
|
<T> reactor.core.publisher.Mono<Long> |
count(Class<T> entityClass,
com.google.firestore.v1.StructuredQuery.Builder queryBuilder)
Count entities of the given domain corresponding to the predicates given in the query builder.
|
<T> reactor.core.publisher.Mono<Void> |
delete(org.reactivestreams.Publisher<T> entityPublisher)
Delete entities provided by publisher.
|
<T> reactor.core.publisher.Mono<Long> |
deleteAll(Class<T> clazz)
Delete all entities of a given domain type.
|
<T> reactor.core.publisher.Mono<Void> |
deleteById(org.reactivestreams.Publisher<String> idPublisher,
Class entityClass)
Delete entities of a given domain type using ids published by producer.
|
<T> reactor.core.publisher.Flux<T> |
execute(com.google.firestore.v1.StructuredQuery.Builder builder,
Class<T> entityType) |
<T> reactor.core.publisher.Mono<Boolean> |
existsById(org.reactivestreams.Publisher<String> idPublisher,
Class<T> entityClass)
Test if the entity of the given domain type with a given id exists.
|
<T> reactor.core.publisher.Flux<T> |
findAll(Class<T> clazz)
Get all the entities of the given domain type.
|
<T> reactor.core.publisher.Flux<T> |
findAllById(org.reactivestreams.Publisher<String> idPublisher,
Class<T> entityClass)
Get an entity of the given domain type by id.
|
<T> reactor.core.publisher.Mono<T> |
findById(org.reactivestreams.Publisher<String> idPublisher,
Class<T> entityClass)
Get an entity of the given domain type by id.
|
FirestoreClassMapper |
getClassMapper() |
FirestoreMappingContext |
getMappingContext() |
int |
getWriteBufferSize() |
Duration |
getWriteBufferTimeout() |
boolean |
isUsingStreamTokens() |
<T> reactor.core.publisher.Mono<T> |
save(T entity)
Saves an instance of an object to Cloud Firestore.
|
<T> reactor.core.publisher.Flux<T> |
saveAll(org.reactivestreams.Publisher<T> instances)
Saves multiple objects to Cloud Firestore.
|
void |
setUsingStreamTokens(boolean usingStreamTokens)
Sets whether the
FirestoreTemplate should attach stream resume tokens to write
requests. |
void |
setWriteBufferSize(int bufferWriteSize)
Sets how many entities to include in an insert/update/delete buffered operation.
|
void |
setWriteBufferTimeout(Duration bufferTimeout)
Sets the
Duration for how long to wait for the entity buffer to fill before sending
the buffered entities to Firestore for insert/update/delete operations. |
public FirestoreTemplate(com.google.firestore.v1.FirestoreGrpc.FirestoreStub firestore,
String parent,
FirestoreClassMapper classMapper,
FirestoreMappingContext mappingContext)
firestore - Firestore gRPC stubparent - the parent resource. For example:
projects/{project_id}/databases/{database_id}/documents orclassMapper - a FirestoreClassMapper used for conversionmappingContext - Mapping Contextpublic void setWriteBufferTimeout(Duration bufferTimeout)
Duration for how long to wait for the entity buffer to fill before sending
the buffered entities to Firestore for insert/update/delete operations.bufferTimeout - duration to wait for entity buffer to fill before sending to Firestore.
(default = 500ms)public Duration getWriteBufferTimeout()
public void setWriteBufferSize(int bufferWriteSize)
The maximum buffer size is 500. In most cases users should leave this at the maximum value.
bufferWriteSize - the entity buffer size for buffered operations (default = 500)public int getWriteBufferSize()
public void setUsingStreamTokens(boolean usingStreamTokens)
FirestoreTemplate should attach stream resume tokens to write
requests.
Note that this should always be set to true unless you are using the Firestore emulator in which case it should be set to false because the emulator does not support using resume tokens.
usingStreamTokens - whether the template should use stream tokenspublic boolean isUsingStreamTokens()
public <T> reactor.core.publisher.Mono<Boolean> existsById(org.reactivestreams.Publisher<String> idPublisher, Class<T> entityClass)
FirestoreReactiveOperationsexistsById in interface FirestoreReactiveOperationsT - the type param of the domain type.idPublisher - publisher that provides an id.entityClass - the domain type of the entity.Mono emitting true if an entity with the given id exists, false otherwise.public <T> reactor.core.publisher.Mono<T> findById(org.reactivestreams.Publisher<String> idPublisher, Class<T> entityClass)
FirestoreReactiveOperationsfindById in interface FirestoreReactiveOperationsT - the type param of the domain type.idPublisher - publisher that provides an id.entityClass - the domain type of the entity.Mono emitting the found entity.public <T> reactor.core.publisher.Flux<T> findAllById(org.reactivestreams.Publisher<String> idPublisher, Class<T> entityClass)
FirestoreReactiveOperationsfindAllById in interface FirestoreReactiveOperationsT - the type param of the domain type.idPublisher - publisher that provides ids.entityClass - the domain type of the entity.Flux emitting the found entities.public <T> reactor.core.publisher.Mono<T> save(T entity)
FirestoreReactiveOperationssave in interface FirestoreReactiveOperationsT - the type of the object to save.entity - the instance to save.Mono emitting the saved entity.public <T> reactor.core.publisher.Flux<T> saveAll(org.reactivestreams.Publisher<T> instances)
The buffer size and buffer timeout settings for saveAll(org.reactivestreams.Publisher<T>) can be modified by calling
setWriteBufferSize(int) and setWriteBufferTimeout(java.time.Duration).
saveAll in interface FirestoreReactiveOperationsT - the type of the objects to save.instances - the objects to save.Flux emitting the saved entities.public <T> reactor.core.publisher.Flux<T> findAll(Class<T> clazz)
FirestoreReactiveOperationsfindAll in interface FirestoreReactiveOperationsT - the type param of the domain type.clazz - the domain type to get.Mono emitting the found entities.public <T> reactor.core.publisher.Mono<Long> count(Class<T> entityClass)
FirestoreReactiveOperationscount in interface FirestoreReactiveOperationsT - the type param of the domain type.entityClass - the domain type of entities.Mono emitting the number of entities.public <T> reactor.core.publisher.Mono<Long> count(Class<T> entityClass, com.google.firestore.v1.StructuredQuery.Builder queryBuilder)
FirestoreReactiveOperationscount in interface FirestoreReactiveOperationsT - the type param of the domain type.entityClass - the domain type of entities.queryBuilder - the query builder that contains predicates;
note that id projection and the collection name will be set during executionMono emitting the number of entities.public <T> reactor.core.publisher.Mono<Long> deleteAll(Class<T> clazz)
The buffer size and buffer timeout settings for saveAll(org.reactivestreams.Publisher<T>) can be modified by calling
setWriteBufferSize(int) and setWriteBufferTimeout(java.time.Duration).
deleteAll in interface FirestoreReactiveOperationsT - the type param of the domain type.clazz - the domain type to delete from Cloud Datastore.Mono emitting the number of deleted entities.public <T> reactor.core.publisher.Mono<Void> delete(org.reactivestreams.Publisher<T> entityPublisher)
The buffer size and buffer timeout settings for saveAll(org.reactivestreams.Publisher<T>) can be modified by calling
setWriteBufferSize(int) and setWriteBufferTimeout(java.time.Duration).
delete in interface FirestoreReactiveOperationsT - the type param of the domain type.entityPublisher - publisher that provides entities to be removed.Mono signaling when operation has completed.public <T> reactor.core.publisher.Mono<Void> deleteById(org.reactivestreams.Publisher<String> idPublisher, Class entityClass)
The buffer size and buffer timeout settings for saveAll(org.reactivestreams.Publisher<T>) can be modified by calling
setWriteBufferSize(int) and setWriteBufferTimeout(java.time.Duration).
deleteById in interface FirestoreReactiveOperationsT - the type param of the domain type.idPublisher - publisher that provides ids of entities to be removed.entityClass - the domain type of entities.Mono signaling when operation has completed.public <T> reactor.core.publisher.Flux<T> execute(com.google.firestore.v1.StructuredQuery.Builder builder,
Class<T> entityType)
execute in interface FirestoreReactiveOperationspublic FirestoreMappingContext getMappingContext()
public FirestoreClassMapper getClassMapper()
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.