Class: Google::Cloud::Firestore::QueryPartition
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::QueryPartition
- Defined in:
- lib/google/cloud/firestore/query_partition.rb
Overview
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.
Instance Attribute Summary collapse
-
#end_before ⇒ Array<Object>?
readonly
The cursor values that define the first result after this partition, or
nil
if this is the last partition. -
#start_at ⇒ Array<Object>?
readonly
The cursor values that define the first result for this partition, or
nil
if this is the first partition.
Instance Method Summary collapse
-
#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.
Instance Attribute Details
#end_before ⇒ Array<Object>? (readonly)
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.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/google/cloud/firestore/query_partition.rb', line 53 class QueryPartition attr_reader :start_at attr_reader :end_before ## # @private New QueryPartition from query and Cursor def initialize query, start_at, end_before @query = query @start_at = start_at @end_before = end_before end ## # Creates a new query that only returns the documents for this partition, using the cursor values from # {#start_at} and {#end_before}. # # @return [Query] The query for the partition. # def to_query base_query = @query base_query = base_query.start_at start_at if start_at base_query = base_query.end_before end_before if end_before base_query end end |
#start_at ⇒ Array<Object>? (readonly)
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.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/google/cloud/firestore/query_partition.rb', line 53 class QueryPartition attr_reader :start_at attr_reader :end_before ## # @private New QueryPartition from query and Cursor def initialize query, start_at, end_before @query = query @start_at = start_at @end_before = end_before end ## # Creates a new query that only returns the documents for this partition, using the cursor values from # {#start_at} and {#end_before}. # # @return [Query] The query for the partition. # def to_query base_query = @query base_query = base_query.start_at start_at if start_at base_query = base_query.end_before end_before if end_before base_query end end |
Instance Method Details
#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.
71 72 73 74 75 76 |
# File 'lib/google/cloud/firestore/query_partition.rb', line 71 def to_query base_query = @query base_query = base_query.start_at start_at if start_at base_query = base_query.end_before end_before if end_before base_query end |