Reference documentation and code samples for the Cloud Firestore Client class FieldValue.
Provides special field values for Cloud Firestore.
This class cannot be instantiated, and methods contained within it should be
accessed statically.
Namespace
Google \ Cloud \ Firestore
Methods
static::deleteField
Denotes a field which should be deleted from a Firestore Document.
This special value, when used as a field value on update calls, will
cause the field to be entirely deleted from Cloud Firestore.
Example:
use Google\Cloud\Firestore\FieldValue;
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient;
$document = $firestore->document('users/dave');
$document->update([
[
'path' => 'hometown',
'value' => FieldValue::deleteField()
]
]);
Returns
Type
Description
FieldValue\DeleteFieldValue
static::serverTimestamp
Denotes a field which should be set to the server timestamp.
This special value, when used as a field value on create, update or set
calls, will cause the field value to be set to the current server
timestamp.
Example:
use Google\Cloud\Firestore\FieldValue;
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient;
$document = $firestore->document('users/dave');
$document->update([
[
'path' => 'lastLogin',
'value' => FieldValue::serverTimestamp()
]
]);
Returns
Type
Description
FieldValue\ServerTimestampValue
static::arrayUnion
Returns a special value that can be used with set(), create() or update()
that tells the server to union the given elements with any array value
that already exists on the server. Each specified element that doesn't
already exist in the array will be added to the end. If the field being
modified is not already an array it will be overwritten with an array
containing exactly the specified elements.
Example:
use Google\Cloud\Firestore\FieldValue;
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient;
$document = $firestore->document('users/dave');
$document->update([
[
'path' => 'favoriteColors',
'value' => FieldValue::arrayUnion(['red', 'blue'])
]
]);
Parameter
Name
Description
elements
array
The elements to union into the array.
Returns
Type
Description
FieldValue\ArrayUnionValue
static::arrayRemove
Returns a special value that can be used with set(), create() or update()
that tells the server to remove the given elements from any array value
that already exists on the server. All instances of each element
specified will be removed from the array. If the field being modified is
not already an array it will be overwritten with an empty array.
Example:
use Google\Cloud\Firestore\FieldValue;
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient;
$document = $firestore->document('users/dave');
$document->update([
[
'path' => 'favoriteColors',
'value' => FieldValue::arrayRemove(['green'])
]
]);
Parameter
Name
Description
elements
array
The elements to remove from the array.
Returns
Type
Description
FieldValue\ArrayRemoveValue
static::increment
Returns a special value that can be used with set() or update() that
tells the server to add the given value to the field's current value.
Given value must be an integer or a double value. If the field is not an
integer or double, or if the field does not yet exist, the
transformation will set the field to the given value. If either of the
given value or the current field value are doubles, both values will be
interpreted as doubles. Double arithmetic and representation of double
values follow IEEE 754 semantics. If there is positive/negative integer
overflow, the field is resolved to the largest magnitude
positive/negative integer.
Example:
use Google\Cloud\Firestore\FieldValue;
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient;
$document = $firestore->document('users/dave');
$document->update([
[
'path' => 'loginCount',
'value' => FieldValue::increment(1)
]
]);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Firestore Client - Class FieldValue (1.53.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.53.0 (latest)](/php/docs/reference/cloud-firestore/latest/FieldValue)\n- [1.52.0](/php/docs/reference/cloud-firestore/1.52.0/FieldValue)\n- [1.51.0](/php/docs/reference/cloud-firestore/1.51.0/FieldValue)\n- [1.50.0](/php/docs/reference/cloud-firestore/1.50.0/FieldValue)\n- [1.48.1](/php/docs/reference/cloud-firestore/1.48.1/FieldValue)\n- [1.47.3](/php/docs/reference/cloud-firestore/1.47.3/FieldValue)\n- [1.46.0](/php/docs/reference/cloud-firestore/1.46.0/FieldValue)\n- [1.45.2](/php/docs/reference/cloud-firestore/1.45.2/FieldValue)\n- [1.44.1](/php/docs/reference/cloud-firestore/1.44.1/FieldValue)\n- [1.43.3](/php/docs/reference/cloud-firestore/1.43.3/FieldValue)\n- [1.40.0](/php/docs/reference/cloud-firestore/1.40.0/FieldValue)\n- [1.39.0](/php/docs/reference/cloud-firestore/1.39.0/FieldValue)\n- [1.38.0](/php/docs/reference/cloud-firestore/1.38.0/FieldValue)\n- [1.37.7](/php/docs/reference/cloud-firestore/1.37.7/FieldValue)\n- [1.36.1](/php/docs/reference/cloud-firestore/1.36.1/FieldValue)\n- [1.35.0](/php/docs/reference/cloud-firestore/1.35.0/FieldValue)\n- [1.34.0](/php/docs/reference/cloud-firestore/1.34.0/FieldValue)\n- [1.33.0](/php/docs/reference/cloud-firestore/1.33.0/FieldValue)\n- [1.32.0](/php/docs/reference/cloud-firestore/1.32.0/FieldValue)\n- [1.31.0](/php/docs/reference/cloud-firestore/1.31.0/FieldValue)\n- [1.30.0](/php/docs/reference/cloud-firestore/1.30.0/FieldValue)\n- [1.28.0](/php/docs/reference/cloud-firestore/1.28.0/FieldValue)\n- [1.27.3](/php/docs/reference/cloud-firestore/1.27.3/FieldValue) \nReference documentation and code samples for the Cloud Firestore Client class FieldValue.\n\nProvides special field values for Cloud Firestore.\n\nThis class cannot be instantiated, and methods contained within it should be\naccessed statically.\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Firestore\n\nMethods\n-------\n\n### static::deleteField\n\nDenotes a field which should be deleted from a Firestore Document.\n\nThis special value, when used as a field value on update calls, will\ncause the field to be entirely deleted from Cloud Firestore.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FieldValue;\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient;\n $document = $firestore-\u003edocument('users/dave');\n $document-\u003eupdate([\n [\n 'path' =\u003e 'hometown',\n 'value' =\u003e FieldValue::deleteField()\n ]\n ]);\n\n### static::serverTimestamp\n\nDenotes a field which should be set to the server timestamp.\n\nThis special value, when used as a field value on create, update or set\ncalls, will cause the field value to be set to the current server\ntimestamp.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FieldValue;\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient;\n $document = $firestore-\u003edocument('users/dave');\n $document-\u003eupdate([\n [\n 'path' =\u003e 'lastLogin',\n 'value' =\u003e FieldValue::serverTimestamp()\n ]\n ]);\n\n### static::arrayUnion\n\nReturns a special value that can be used with set(), create() or update()\nthat tells the server to union the given elements with any array value\nthat already exists on the server. Each specified element that doesn't\nalready exist in the array will be added to the end. If the field being\nmodified is not already an array it will be overwritten with an array\ncontaining exactly the specified elements.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FieldValue;\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient;\n $document = $firestore-\u003edocument('users/dave');\n\n $document-\u003eupdate([\n [\n 'path' =\u003e 'favoriteColors',\n 'value' =\u003e FieldValue::arrayUnion(['red', 'blue'])\n ]\n ]);\n\n### static::arrayRemove\n\nReturns a special value that can be used with set(), create() or update()\nthat tells the server to remove the given elements from any array value\nthat already exists on the server. All instances of each element\nspecified will be removed from the array. If the field being modified is\nnot already an array it will be overwritten with an empty array.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FieldValue;\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient;\n $document = $firestore-\u003edocument('users/dave');\n\n $document-\u003eupdate([\n [\n 'path' =\u003e 'favoriteColors',\n 'value' =\u003e FieldValue::arrayRemove(['green'])\n ]\n ]);\n\n### static::increment\n\nReturns a special value that can be used with set() or update() that\ntells the server to add the given value to the field's current value.\n\nGiven value must be an integer or a double value. If the field is not an\ninteger or double, or if the field does not yet exist, the\ntransformation will set the field to the given value. If either of the\ngiven value or the current field value are doubles, both values will be\ninterpreted as doubles. Double arithmetic and representation of double\nvalues follow IEEE 754 semantics. If there is positive/negative integer\noverflow, the field is resolved to the largest magnitude\npositive/negative integer.\n\nExample: \n\n use Google\\Cloud\\Firestore\\FieldValue;\n use Google\\Cloud\\Firestore\\FirestoreClient;\n\n $firestore = new FirestoreClient;\n $document = $firestore-\u003edocument('users/dave');\n\n $document-\u003eupdate([\n [\n 'path' =\u003e 'loginCount',\n 'value' =\u003e FieldValue::increment(1)\n ]\n ]);"]]