Cloud Firestore API - Class Google::Cloud::Firestore::QueryPartition (v2.9.1)

Reference documentation and code samples for the Cloud Firestore API class Google::Cloud::Firestore::QueryPartition.

QueryPartition

Represents a split point that can be used in a query as a starting and/or end point for the query results.

The cursors returned by #start_at and #end_before can only be used in a query that matches the constraint of the query that produced this partition.

See CollectionGroup#partitions and Query.

Inherits

  • Object

Example

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

col_group = firestore.col_group "cities"

partitions = col_group.partitions 3

queries = partitions.map(&:to_query)

Methods

#end_before

def end_before() -> Array<Object>, nil

The cursor values that define the first result after this partition, or nil if this is the last partition. Returns an array of values that represent a position, in the order they appear in the order by clause of the query. Can contain fewer values than specified in the order by clause. Will be used in the query returned by #to_query.

Returns

#start_at

def start_at() -> Array<Object>, nil

The cursor values that define the first result for this partition, or nil if this is the first partition. Returns an array of values that represent a position, in the order they appear in the order by clause of the query. Can contain fewer values than specified in the order by clause. Will be used in the query returned by #to_query.

Returns

#to_query

def to_query() -> Query

Creates a new query that only returns the documents for this partition, using the cursor values from #start_at and #end_before.

Returns
  • (Query) — The query for the partition.