lib/google/cloud/firestore/document_reference.rb in google-cloud-firestore-2.8.0 vs lib/google/cloud/firestore/document_reference.rb in google-cloud-firestore-2.9.0

- old
+ new

@@ -71,10 +71,13 @@ # @!group Access ## # Retrieves an enumerator for the collections nested under the document snapshot. # + # @param [Time] read_time Reads documents as they were at the given time. + # This may not be older than 270 seconds. Optional + # # @yield [collections] The block for accessing the collections. # @yieldparam [CollectionReference] collection A collection reference object. # # @return [Enumerator<CollectionReference>] An enumerator of collection references. If a block is provided, this # is the same enumerator that is accessed through the block. @@ -89,13 +92,27 @@ # # nyc_ref.cols.each do |col| # puts col.collection_id # end # - def cols &block + # @example Get collection with read time + # require "google/cloud/firestore" + # + # firestore = Google::Cloud::Firestore.new + # + # read_time = Time.now + # + # # Get a document reference + # nyc_ref = firestore.doc "cities/NYC" + # + # nyc_ref.cols(read_time: read_time).each do |col| + # puts col.collection_id + # end + # + def cols read_time: nil, &block ensure_service! - grpc = service.list_collections path - cols_enum = CollectionReferenceList.from_grpc(grpc, client, path).all + grpc = service.list_collections path, read_time: read_time + cols_enum = CollectionReferenceList.from_grpc(grpc, client, path, read_time: read_time).all cols_enum.each(&block) if block_given? cols_enum end alias collections cols alias list_collections cols