Reference documentation and code samples for the google-cloud-firestore class Google::Cloud::Firestore::QuerySnapshot.
QuerySnapshot
A query snapshot object is an immutable representation of query results, including chnages from the previous snapshot.
Inherits
- Object
Example
require "google/cloud/firestore" firestore = Google::Cloud::Firestore.new # Create a query query = firestore.col(:cities).order(:population, :desc) listener = query.listen do |snapshot| puts "The query snapshot has #{snapshot.docs.count} documents " puts "and has #{snapshot.changes.count} changes." end # When ready, stop the listen operation and close the stream. listener.stop
Methods
#changes
def changes() -> Array<DocumentChange>
The document change objects for the query snapshot.
- (Array<DocumentChange>) — document changes.
#count
def count() -> Integer
Returns the number of documents in this query snapshot.
- (Integer) — The number of documents.
#doc_changes
def doc_changes() -> Array<DocumentChange>
The document change objects for the query snapshot.
- (Array<DocumentChange>) — document changes.
#docs
def docs() -> Array<DocumentSnapshot>
The documents in the snapshot.
- (Array<DocumentSnapshot>) — document snapshots.
#document_changes
def document_changes() -> Array<DocumentChange>
The document change objects for the query snapshot.
- (Array<DocumentChange>) — document changes.
#documents
def documents() -> Array<DocumentSnapshot>
The documents in the snapshot.
- (Array<DocumentSnapshot>) — document snapshots.
#empty?
def empty?() -> Boolean
Determines whether query results exists.
- (Boolean) — Whether query results exists.
#query
def query() -> Query
The query producing this snapshot.
- (Query) — query.
#read_at
def read_at() -> Time
The time at which the snapshot was read.
- (Time) — The time at which the documents were read.
#read_time
def read_time() -> Time
The time at which the snapshot was read.
- (Time) — The time at which the documents were read.
#size
def size() -> Integer
Returns the number of documents in this query snapshot.
- (Integer) — The number of documents.