Sentinel values that can be used when writing document fields withset()orupdate().

Index

Constructors

Private constructor

Methods

isEqual

  • isEqual(otherFieldValue):boolean
  • Returns true if thisFieldValue is equal to the provided one.

    Parameters

    Returnsboolean

    true if thisFieldValue is equal to the provided one.

Static arrayRemove

  • arrayRemove(...elementsany[]):FieldValue
  • Returns a special value that can be used withset() orupdate() that tellsthe server to remove the given elements from any array value that alreadyexists on the server. All instances of each element specified will beremoved from the array. If the field being modified is not already anarray it will be overwritten with an empty array.

    Parameters

    • Rest...elements:any[]

      The elements to remove from the array.

    ReturnsFieldValue

    The FieldValue sentinel for use in a call toset() orupdate().

Static arrayUnion

  • arrayUnion(...elementsany[]):FieldValue
  • Returns a special value that can be used withset() orupdate() that tellsthe server to union the given elements with any array value that alreadyexists on the server. Each specified element that doesn't already exist inthe array will be added to the end. If the field being modified is notalready an array it will be overwritten with an array containing exactlythe specified elements.

    Parameters

    • Rest...elements:any[]

      The elements to union into the array.

    ReturnsFieldValue

    The FieldValue sentinel for use in a call toset() orupdate().

Static delete

  • delete():FieldValue
  • Returns a sentinel for use withupdate() to mark a field for deletion.

    ReturnsFieldValue

Static increment

  • increment(nnumber):FieldValue
  • Returns a special value that can be used withset() orupdate() that tellsthe server to increment the field's current value by the given value.

    If either the operand or the current field value uses floating point precision,all arithmetic follows IEEE 754 semantics. If both values are integers,values outside of JavaScript's safe number range (Number.MIN_SAFE_INTEGER toNumber.MAX_SAFE_INTEGER) are also subject to precision loss. Furthermore,once processed by the Firestore backend, all integer operations are cappedbetween -2^63 and 2^63-1.

    If the current field value is not of typenumber, or if the field does notyet exist, the transformation sets the field to the given value.

    Parameters

    • n:number

      The value to increment by.

    ReturnsFieldValue

    The FieldValue sentinel for use in a call toset() orupdate().

Static serverTimestamp

  • serverTimestamp():FieldValue
  • Returns a sentinel used withset() orupdate() to include aserver-generated timestamp in the written data.

    ReturnsFieldValue

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-27 UTC.