A Firestore query.
JSON representation |
---|
{ "select": { object ( |
Fields | |
---|---|
select |
The projection to return. |
from[] |
The collections to query. |
where |
The filter to apply. |
orderBy[] |
The order to apply to the query results. Firestore allows callers to provide a full ordering, a partial ordering, or no ordering at all. In all cases, Firestore guarantees a stable ordering through the following rules:
Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example:
|
startAt |
A potential prefix of a position in the result set to start the query at. The ordering of the result set is based on the
This query's results are ordered by Cursors can reference either the full ordering or a prefix of the location, though it cannot reference more fields than what are in the provided Continuing off the example above, attaching the following start cursors will have varying impact:
Unlike Requires:
|
endAt |
A potential prefix of a position in the result set to end the query at. This is similar to Requires:
|
offset |
The number of documents to skip before returning the first result. This applies after the constraints specified by the Requires:
|
limit |
The maximum number of results to return. Applies after all other constraints. Requires:
|
Projection
The projection of document's fields to return.
JSON representation |
---|
{
"fields": [
{
object ( |
Fields | |
---|---|
fields[] |
The fields to return. If empty, all fields are returned. To only return the name of the document, use |
FieldReference
A reference to a field in a document, ex: stats.operations
.
JSON representation |
---|
{ "fieldPath": string } |
Fields | |
---|---|
fieldPath |
The relative path of the document being referenced. Requires:
|
CollectionSelector
A selection of a collection, such as messages as m1
.
JSON representation |
---|
{ "collectionId": string, "allDescendants": boolean } |
Fields | |
---|---|
collectionId |
The collection ID. When set, selects only collections with this ID. |
allDescendants |
When false, selects only collections that are immediate children of the |
Filter
A filter.
JSON representation |
---|
{ // Union field |
Fields | |
---|---|
Union field filter_type . The type of filter. filter_type can be only one of the following: |
|
compositeFilter |
A composite filter. |
fieldFilter |
A filter on a document field. |
unaryFilter |
A filter that takes exactly one argument. |
CompositeFilter
A filter that merges multiple other filters using the given operator.
JSON representation |
---|
{ "op": enum ( |
Fields | |
---|---|
op |
The operator for combining multiple filters. |
filters[] |
The list of filters to combine. Requires:
|
Operator
A composite filter operator.
Enums | |
---|---|
OPERATOR_UNSPECIFIED |
Unspecified. This value must not be used. |
AND |
Documents are required to satisfy all of the combined filters. |
FieldFilter
A filter on a specific field.
JSON representation |
---|
{ "field": { object ( |
Fields | |
---|---|
field |
The field to filter by. |
op |
The operator to filter by. |
value |
The value to compare to. |
Operator
A field filter operator.
Enums | |
---|---|
OPERATOR_UNSPECIFIED |
Unspecified. This value must not be used. |
LESS_THAN |
The given Requires:
|
LESS_THAN_OR_EQUAL |
The given Requires:
|
GREATER_THAN |
The given Requires:
|
GREATER_THAN_OR_EQUAL |
The given Requires:
|
EQUAL |
The given field is equal to the given value . |
NOT_EQUAL |
The given Requires:
|
ARRAY_CONTAINS |
The given field is an array that contains the given value . |
IN |
The given Requires:
|
ARRAY_CONTAINS_ANY |
The given Requires:
|
NOT_IN |
The value of the Requires:
|
UnaryFilter
A filter with a single operand.
JSON representation |
---|
{ "op": enum ( |
Fields | |
---|---|
op |
The unary operator to apply. |
Union field operand_type . The argument to the filter. operand_type can be only one of the following: |
|
field |
The field to which to apply the operator. |
Operator
A unary operator.
Enums | |
---|---|
OPERATOR_UNSPECIFIED |
Unspecified. This value must not be used. |
IS_NAN |
The given field is equal to NaN . |
IS_NULL |
The given field is equal to NULL . |
IS_NOT_NAN |
The given Requires:
|
IS_NOT_NULL |
The given Requires:
|
Order
An order on a field.
JSON representation |
---|
{ "field": { object ( |
Fields | |
---|---|
field |
The field to order by. |
direction |
The direction to order by. Defaults to |
Direction
A sort direction.
Enums | |
---|---|
DIRECTION_UNSPECIFIED |
Unspecified. |
ASCENDING |
Ascending. |
DESCENDING |
Descending. |