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
| Parameters | |
|---|---|
| Name | Description |
query | Query The Query which generated this snapshot. |
rows | array<DocumentSnapshot> The query result rows. |
explainMetrics | null|V1\ExplainMetrics |
isEmpty
Check if the result is empty.
Example:
$empty = $snapshot->isEmpty(); | Returns | |
|---|---|
| Type | Description |
bool|null | |
size
Returns the size of the result set.
Example:
$size = $snapshot->size(); | Returns | |
|---|---|
| Type | Description |
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(); | Returns | |
|---|---|
| Type | Description |
array<DocumentSnapshot> | |
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.
| Returns | |
|---|---|
| Type | Description |
null|V1\ExplainMetrics | |
getIterator
| Returns | |
|---|---|
| Type | Description |
ArrayIterator | |