Cloud Firestore Client - Class FieldPath (1.36.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
NameDescription
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
NameDescription
part string

The child path part.

Returns
TypeDescription
Google\Cloud\Firestore\FieldPath

pathString

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

Example:

$string = $path->pathString();
Returns
TypeDescription
string

path

Get the path elements.

Returns
TypeDescription
array

__toString

Cast the path to a string.

Returns
TypeDescription
string

static::documentId

Create a field path indicating the document ID.

Example:

use Google\Cloud\Firestore\FieldPath;

$path = FieldPath::documentId();
Returns
TypeDescription
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
NameDescription
path string

The field path string.

splitPath bool

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

Returns
TypeDescription
Google\Cloud\Firestore\FieldPath

Constants

SPECIAL_CHARS

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

UNESCAPED_FIELD_NAME

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