Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Query

  1. Object
  2. Query

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.

Methods

public static Query collection(String collectionId)Starts a query over one collection.
public static Query collectionGroup(String collectionId)Starts a query over every collection with this ID at any depth.
public String getCollectionId()
public Query where(String field, String op, Object value)Adds a field filter.
public Query orderBy(String field, boolean ascending)Adds a sort order.
public Query limit(int limit)Limits the number of results.
public Query offset(int offset)Skips results.
public Query select(String... fields)Returns only the listed fields.
public Map<String, Object> toStructuredQuery()
public String toString()Returns a string representation of the object.

Inherited methods

Method details

collection

public static Query collection(String collectionId)
Starts a query over one collection.

Parameters

collectionId String
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 String
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 String
the field path
op String
one of the operators listed in the class description
value Object
the operand, encoded with FirestoreValues

Returns

this query

orderBy

public Query orderBy(String field, boolean ascending)
Adds a sort order.

Parameters

field String
the field path
ascending boolean
true for ascending order

Returns

this query

limit

public Query limit(int limit)
Limits the number of results.

Parameters

limit int
the maximum number of documents

Returns

this query

offset

public Query offset(int offset)
Skips results.

Parameters

offset int
the number of documents to skip

Returns

this query

select

public Query select(String... fields)
Returns only the listed fields.

Parameters

fields String...
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()
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())