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)
Executes a query represented as query builder and returns results of the given domain type.
|
<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. |
<T> FirestoreReactiveOperations |
withParent(T parent)
Creates FirestoreReactiveOperations object with a provided parent.
|
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}/documentsclassMapper
- a FirestoreClassMapper
used for conversionmappingContext
- Mapping Contextpublic <T> FirestoreReactiveOperations withParent(T parent)
FirestoreReactiveOperations
withParent
in interface FirestoreReactiveOperations
T
- the type param of the parent.parent
- the query builder.public 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)
FirestoreReactiveOperations
existsById
in interface FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
findById
in interface FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
findAllById
in interface FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
save
in interface FirestoreReactiveOperations
T
- 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 FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
findAll
in interface FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
count
in interface FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
count
in interface FirestoreReactiveOperations
T
- 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 FirestoreReactiveOperations
T
- 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 FirestoreReactiveOperations
T
- 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 FirestoreReactiveOperations
T
- 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)
FirestoreReactiveOperations
execute
in interface FirestoreReactiveOperations
T
- the type param of the domain type.builder
- the query builder.entityType
- the domain type of entities.Flux
emitting the found entities.public FirestoreMappingContext getMappingContext()
public FirestoreClassMapper getClassMapper()
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.