Reference documentation and code samples for the Cloud Firestore API class Google::Cloud::Firestore::CollectionGroup.
CollectionGroup
A collection group object is used for adding documents, getting document references, and querying for documents, including with partitions.
Inherits
Example
require "google/cloud/firestore" firestore = Google::Cloud::Firestore.new # Get a collection group col_group = firestore.col_group "cities" # Get and print all city documents col_group.get do |city| puts "#{city.document_id} has #{city[:population]} residents." end
Methods
#partitions
def partitions(partition_count) -> Array<QueryPartition>
Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used as starting/end points for the query results.
- partition_count (Integer) — The desired maximum number of partition points. The number must be strictly positive. The actual number of partitions returned may be fewer.
- (Array<QueryPartition>) — An ordered array of query partitions.
- (ArgumentError)
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)