FieldValue class abstract

Special values for writes: they tell the server how to change a field instead of giving its new value.

Use them as values in the data of set and update (on a DocumentReference, a WriteBatch or a Transaction). They cannot be used in queries, and not inside an array value: there the call fails with an ArgumentError.

await firestore.doc('cities/SF').update(<String, Object?>{
  'population': FieldValue.increment(1),
  'tags': FieldValue.arrayUnion(<Object?>['coastal']),
  'updatedAt': FieldValue.serverTimestamp(),
  'obsolete': FieldValue.delete(),
});

Outside a transaction, the client applies the transforms to its local cache at once, so listeners see an estimate before the server confirms the write (a pending server timestamp is read as null unless you choose another ServerTimestampBehavior). A document can hold at most 500 field transforms in one write.

Constructors

FieldValue.arrayRemove(Iterable<Object?> elements)
Removes every value equal to one of elements from the array in the field.
factory
FieldValue.arrayUnion(Iterable<Object?> elements)
Adds each of elements to the end of the array in the field, unless the array already contains an equal value.
factory
FieldValue.delete()
Removes the field from the document.
factory
FieldValue.increment(num value)
Adds value to the number in the field; use a negative value to subtract.
factory
FieldValue.maximum(num value)
Sets the field to the larger of its current value and value.
factory
FieldValue.minimum(num value)
Sets the field to the smaller of its current value and value.
factory
FieldValue.serverTimestamp()
Sets the field to the time at which the server applies the write.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited