Cloud Firestore Client - Class Filter (1.45.2)

Reference documentation and code samples for the Cloud Firestore Client class Filter.

A Query Filter class.

This class helps the user to create filters for complex queries.

Example:

use Google\Cloud\Firestore\Filter;

// Filtering with Filter::or and Filter::field
$result = $query->where(Filter::or([
    Filter::field('firstName', '=', 'John'),
    Filter::field('firstName', '=', 'Monica')
]));

Namespace

Google \ Cloud \ Firestore

Methods

static::and

Helper function for and filter.

Example:

use Google\Cloud\Firestore\Filter;

$result = $query->where(Filter::and([
    Filter::field('firstName', '=', 'John'),
    Filter::field('age', '>', '25')
]));
Parameter
Name Description
filters array

A filter array.

Returns
Type Description
array A composite filter array.

static::or

Helper function for or filter.

Example:

use Google\Cloud\Firestore\Filter;

$result = $query->where(Filter::or([
    Filter::field('firstName', '=', 'John'),
    Filter::field('firstName', '=', 'Monica')
]));
Parameter
Name Description
filters array

A filter array.

Returns
Type Description
array A composite Filter array.

static::field

Helper function for field filter.

Example:

use Google\Cloud\Firestore\Filter;

$result = $query->where(Filter::field('firstName', '=', 'John'));
Parameters
Name Description
fieldPath string|Google\Cloud\Firestore\FieldPath

A field to filter by.

operator string|int

An operator to filter by.

value mixed

A value to compare to.

Returns
Type Description
array A field Filter array.