Write

A write on a document.

JSON representation
{
  "updateMask": {
    object(DocumentMask)
  },
  "currentDocument": {
    object(Precondition)
  },

  // Union field operation can be only one of the following:
  "update": {
    object(Document)
  },
  "delete": string,
  "transform": {
    object(DocumentTransform)
  },
  // End of list of possible types for union field operation.
}
Fields
updateMask

object(DocumentMask)

The fields to update in this write.

This field can be set only when the operation is update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. The field paths in this mask must not contain a reserved field name.

currentDocument

object(Precondition)

An optional precondition on the document.

The write will fail if this is set and not met by the target document.

Union field operation. The operation to execute. operation can be only one of the following:
update

object(Document)

A document to write.

delete

string

A document name to delete. In the format: projects/{projectId}/databases/{databaseId}/documents/{document_path}.

transform

object(DocumentTransform)

Applies a tranformation to a document. At most one transform per document is allowed in a given request. An update cannot follow a transform on the same document in a given request.

DocumentTransform

A transformation of a document.

JSON representation
{
  "document": string,
  "fieldTransforms": [
    {
      object(FieldTransform)
    }
  ],
}
Fields
document

string

The name of the document to transform.

fieldTransforms[]

object(FieldTransform)

The list of transformations to apply to the fields of the document, in order. This must not be empty.

FieldTransform

A transformation of a field of the document.

JSON representation
{
  "fieldPath": string,
  "setToServerValue": enum(ServerValue),
}
Fields
fieldPath

string

The path of the field. See Document.fields for the field path syntax reference.

setToServerValue

enum(ServerValue)

Sets the field to the given server value.

ServerValue

A value that is calculated by the server.

Enums
SERVER_VALUE_UNSPECIFIED Unspecified. This value must not be used.
REQUEST_TIME The time at which the server processed the request, with millisecond precision.
Was this page helpful? Let us know how we did: