Class Query

java.lang.Object
com.codename1.cloud.firebase.Query

public final class Query extends Object

Builds a Firestore structured query.

com.codename1.cloud.firebase.Query q = com.codename1.cloud.firebase.Query.collection("cities")
        .where("state", "==", "CA")
        .where("population", ">", 100000)
        .orderBy("population", false)
        .limit(10);
Log.p(q.toString());

Operators: <, <=, >, >=, ==, !=, array-contains, array-contains-any, in and not-in. Several where calls combine with AND.

  • Method Details

    • collection

      public static Query collection(String collectionId)

      Starts a query over one collection.

      Parameters
      • collectionId: the collection ID, such as cities
      Returns

      a new query

    • collectionGroup

      public static Query collectionGroup(String collectionId)

      Starts a query over every collection with this ID at any depth.

      Parameters
      • collectionId: the collection ID
      Returns

      a new collection group query

    • getCollectionId

      public String getCollectionId()
      Returns

      the collection ID this query reads

    • where

      public Query where(String field, String op, Object value)

      Adds a field filter.

      Parameters
      • field: the field path

      • op: one of the operators listed in the class description

      • value: the operand, encoded with FirestoreValues

      Returns

      this query

    • orderBy

      public Query orderBy(String field, boolean ascending)

      Adds a sort order.

      Parameters
      • field: the field path

      • ascending: true for ascending order

      Returns

      this query

    • limit

      public Query limit(int limit)

      Limits the number of results.

      Parameters
      • limit: the maximum number of documents
      Returns

      this query

    • offset

      public Query offset(int offset)

      Skips results.

      Parameters
      • offset: the number of documents to skip
      Returns

      this query

    • select

      public Query select(String... fields)

      Returns only the listed fields.

      Parameters
      • fields: the field paths to return
      Returns

      this query

    • toStructuredQuery

      public Map<String,Object> toStructuredQuery()
      Returns

      the structuredQuery object for a runQuery or Listen request

    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object