-
Notifications
You must be signed in to change notification settings - Fork 0
Reserved Keywords
The following reserved keywords are used as Sentinel values for write request:
Caution
None of these reserved keywords can be used into an array. This is a limitation of Firestore.
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.
The keyword must be used as a key in an object and its value will be added to the array:
{
"ARRAY_UNION": "some-value"
}
The following example adds the string "foo" to the array "my-array":
{
"my-array": {
"ARRAY_UNION": "foo"
}
}
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.
The keyword must be used as a key in an object and its value will be added to the array:
{
"ARRAY_REMOVE": "some-value"
}
The following example removes the string "foo" from the array "my-array":
{
"my-array": {
"ARRAY_REMOVE": "foo"
}
}
To decrement/increment the field's current value by the given value. The value must be a number.
The keyword must be used as the following string: INCREMENT [delta]
or DECREMENT [delta]
.
The following example increments by 2 the value of "index":
{
"index": "INCREMENT 2"
}
To mark a field for deletion.
The keyword must be used as the following string: DELETE
.
The following example deletes the "field-to-keep" field and it's value from the object:
{
"field-to-delete": "DELETE"
}
To include a server-generated Geo Point in the written data.
The keyword must be used as the following object:
{
"GEO_POINT": {
"latitude": 90,
"longitude": 90
}
}
The following example defines a Geo Point for the "location" field:
{
"location": {
"GEO_POINT": {
"latitude": 90,
"longitude": 90
}
}
}
To include a server-generated timestamp in the written data.
The keyword must be used as the following string: TIMESTAMP
.
The following example defines the value of "date":
{
"date": "TIMESTAMP"
}