Reference documentation and code samples for the Cloud Firestore Client class QuerySnapshot.
Represents the result set of a Cloud Firestore Query.
Example:
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient();
$collection = $firestore->collection('users');
$query = $collection->where('age', '>', 18);
$snapshot = $query->documents();
// Snapshots can be iterated with foreach:
foreach ($snapshot as $user) {
echo $user['name'] . PHP_EOL;
}
Namespace
Google \ Cloud \ FirestoreMethods
__construct
isEmpty
Check if the result is empty.
Example:
$empty = $snapshot->isEmpty();
bool|null
size
Returns the size of the result set.
Example:
$size = $snapshot->size();
int|null
rows
Return the formatted and decoded rows. If the stream is interrupted, attempts will be made on your behalf to resume.
Example:
$rows = $snapshot->rows();
getExplainMetrics
Gets ExplainMetrics
when the explainOptions
option is supplied.
If ExplainOptions::setAnalyze
is set to false
, the query is
planned and not executed, returning only the V1\PlanSummary
instead of the V1\ExecutionStats
and result.
getIterator
ArrayIterator