FieldValue
Sentinel values that can be used when writing document fields with set()
or update()
.
Example
const increment = firebase.firestore.FieldValue.increment(1);
await firebase.firestore().doc('users/alovelace').update({
age: increment, // increment age by 1
});
Methods
isEqual
</>Returns true if this FieldValue
is equal to the provided one.
isEqual(other: FieldValue): boolean;
arrayRemove
</>Returns a special value that can be used with set()
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.
arrayRemove(elements: any[]): FieldValue;
arrayUnion
</>Returns a special value that can be used with set()
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.
arrayUnion(elements: any[]): FieldValue;
delete
</>Returns a sentinel for use with update() to mark a field for deletion.
delete(): FieldValue;
increment
</>Returns a special value that can be used with set()
or update()
that tells the server to increment the field's current value by the given value.
increment(n: number): FieldValue;
serverTimestamp
</>Returns a sentinel used with set() or update() to include a server-generated timestamp in the written data.
serverTimestamp(): FieldValue;