Cloud Firestore Client - Class Filter (1.40.0)

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
NameDescription
filters array

A filter array.

Returns
TypeDescription
arrayA 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
NameDescription
filters array

A filter array.

Returns
TypeDescription
arrayA composite Filter array.

static::field

Helper function for field filter.

Example:

use Google\Cloud\Firestore\Filter;

$result = $query->where(Filter::field('firstName', '=', 'John'));
Parameters
NameDescription
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
TypeDescription
arrayA field Filter array.