Cloud Firestore Client - Class FieldPath (1.44.1)

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

Represents a path to a Firestore Document field.

Example:

use Google\Cloud\Firestore\FirestoreClient;

$firestore = new FirestoreClient();
$path = $firestore->fieldPath(['accounts', 'usd']);

Namespace

Google \ Cloud \ Firestore

Methods

__construct

Parameter
Name Description
fieldNames array

A list of field names.

child

Get a new FieldPath with the given path part appended to the current path.

Example:

$child = $path->child('element');
Parameter
Name Description
part string

The child path part.

Returns
Type Description
Google\Cloud\Firestore\FieldPath

pathString

Get the current path as a string, with special characters escaped.

Example:

$string = $path->pathString();
Returns
Type Description
string

path

Get the path elements.

Returns
Type Description
array

__toString

Cast the path to a string.

Returns
Type Description
string

static::documentId

Create a field path indicating the document ID.

Example:

use Google\Cloud\Firestore\FieldPath;

$path = FieldPath::documentId();
Returns
Type Description
Google\Cloud\Firestore\FieldPath

static::fromString

Create a FieldPath from a string path.

Example:

use Google\Cloud\Firestore\FieldPath;

$path = FieldPath::fromString('path.to.field');
Parameters
Name Description
path string

The field path string.

splitPath bool

If false, the input path will not be split on .. Defaults to true.

Returns
Type Description
Google\Cloud\Firestore\FieldPath

Constants

SPECIAL_CHARS

Value: '/^[^*~\\/[\\]]+$/'

UNESCAPED_FIELD_NAME

Value: '/^[_a-zA-Z][_a-zA-Z0-9]*$/'