Interface FirestoreReactiveOperations

All Known Implementing Classes:
FirestoreTemplate

public interface FirestoreReactiveOperations
An interface of operations that can be done with Cloud Firestore.
Since:
1.2
  • Method Summary

    Modifier and Type
    Method
    Description
    buildResourceName(FirestorePersistentEntity<?> persistentEntity, String resource)
    Builds the full reference path to a resource such as a document or a sub-collection.
    <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> entityClass)
    Delete all entities of a given domain type.
    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> entityClass)
    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> entityClass)
    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.
    <T> reactor.core.publisher.Mono<T>
    save(T instance)
    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.
    withParent(String id, Class<?> entityClass)
    Creates FirestoreReactiveOperations object with a specified parent document.
    withParent(T parent)
    Creates FirestoreReactiveOperations object with a specified parent document.
  • Method Details

    • save

      <T> reactor.core.publisher.Mono<T> save(T instance)
      Saves an instance of an object to Cloud Firestore. Behaves as an insert only (not update).
      Type Parameters:
      T - the type of the object to save.
      Parameters:
      instance - the instance to save.
      Returns:
      Mono emitting the saved entity.
    • saveAll

      <T> reactor.core.publisher.Flux<T> saveAll(org.reactivestreams.Publisher<T> instances)
      Saves multiple objects to Cloud Firestore. Not atomic. Behaves as insert or update.
      Type Parameters:
      T - the type of the objects to save.
      Parameters:
      instances - the objects to save.
      Returns:
      Flux emitting the saved entities.
    • findAll

      <T> reactor.core.publisher.Flux<T> findAll(Class<T> entityClass)
      Get all the entities of the given domain type.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      entityClass - the domain type to get.
      Returns:
      Mono emitting the found entities.
    • deleteAll

      <T> reactor.core.publisher.Mono<Long> deleteAll(Class<T> entityClass)
      Delete all entities of a given domain type.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      entityClass - the domain type to delete from Cloud Datastore.
      Returns:
      Mono emitting the number of deleted entities.
    • existsById

      <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. Uses the first emitted element to perform the query.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      entityClass - the domain type of the entity.
      idPublisher - publisher that provides an id.
      Returns:
      Mono emitting true if an entity with the given id exists, false otherwise.
    • findById

      <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. Uses the first emitted element to perform the query.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      idPublisher - publisher that provides an id.
      entityClass - the domain type of the entity.
      Returns:
      Mono emitting the found entity.
    • findAllById

      <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.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      idPublisher - publisher that provides ids.
      entityClass - the domain type of the entity.
      Returns:
      Flux emitting the found entities.
    • count

      <T> reactor.core.publisher.Mono<Long> count(Class<T> entityClass)
      Count entities of the given domain. Note that Firestore doesn't support "count" operation natively, so id query will be executed and all ids will be retrieved so they could be counted.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      entityClass - the domain type of entities.
      Returns:
      Mono emitting the number of entities.
    • count

      <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. Note that Firestore doesn't support "count" operation natively, so id query will be executed and all ids will be retrieved so they could be counted.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      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 execution
      Returns:
      Mono emitting the number of entities.
    • delete

      <T> reactor.core.publisher.Mono<Void> delete(org.reactivestreams.Publisher<T> entityPublisher)
      Delete entities provided by publisher.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      entityPublisher - publisher that provides entities to be removed.
      Returns:
      Mono signaling when operation has completed.
    • deleteById

      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.
      Parameters:
      idPublisher - publisher that provides ids of entities to be removed.
      entityClass - the domain type of entities.
      Returns:
      Mono signaling when operation has completed.
    • execute

      <T> reactor.core.publisher.Flux<T> execute(com.google.firestore.v1.StructuredQuery.Builder builder, Class<T> entityClass)
      Executes a query represented as query builder and returns results of the given domain type.
      Type Parameters:
      T - the type param of the domain type.
      Parameters:
      builder - the query builder.
      entityClass - the domain type of entities.
      Returns:
      Flux emitting the found entities.
      Since:
      1.2.4
    • withParent

      <T> FirestoreReactiveOperations withParent(T parent)
      Creates FirestoreReactiveOperations object with a specified parent document. The parent doesn't have to exist in Firestore, but should have a non-empty id field. All operations and queries will be scoped to that parent's subcollections. By default, FirestoreReactiveOperations uses the root document as the parent.
      Type Parameters:
      T - the type param of the parent.
      Parameters:
      parent - the query builder.
      Returns:
      template with a given parent.
      Since:
      1.2.4
    • withParent

      FirestoreReactiveOperations withParent(String id, Class<?> entityClass)
      Creates FirestoreReactiveOperations object with a specified parent document. All operations and queries will be scoped to that parent document's subcollections. By default, FirestoreReactiveOperations uses the root document as the parent.
      Parameters:
      id - the id of the Document entity
      entityClass - the class of the Document entity
      Returns:
      template with a given parent.
      Since:
      2.0.1
    • buildResourceName

      String buildResourceName(FirestorePersistentEntity<?> persistentEntity, String resource)
      Builds the full reference path to a resource such as a document or a sub-collection. This method uses the root collection as the parent (projects/{project_id}/databases/{database_id}/documents/{collection_name}/)
      Parameters:
      persistentEntity - a Firestore persistent entity
      resource - the resource name or path to the resource.
      Returns:
      a String representing the reference path.