Cloud Firestore Client - Class FieldPath (1.30.0)

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']);

Methods

__construct

Parameter
NameDescription
fieldNames array

A list of field names.

documentId

Create a field path indicating the document ID.

Example:

use Google\Cloud\Firestore\FieldPath;

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

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

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

Constants

SPECIAL_CHARS

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

UNESCAPED_FIELD_NAME

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