younifyd
Menu

Firestore.projects.databases.documents.write

Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST).

POST/v1/{database}/documents:write

Use it in a workflow

  1. Add a step and choose the Firestore connector.
  2. Pick the Firestore.projects.databases.documents.write action (under projects).
  3. Fill in the fields below, then reference the result from later steps as {{firestoreProjectsDatabasesDocumentsWrite.response.data}}.

Request

Path parameters

databasestringrequired

Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. This is only required in the first message.

Query parameters

$.xgafvstring

V1 error format.

One of12

access_tokenstring

OAuth access token.

altstring

Data format for response.

One ofjsonmediaproto

callbackstring

JSONP

fieldsstring

Selector specifying which fields to include in a partial response.

keystring

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_tokenstring

OAuth 2.0 token for the current user.

prettyPrintboolean

Returns response with indentations and line breaks.

quotaUserstring

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

upload_protocolstring

Upload protocol for media (e.g. "raw", "multipart").

uploadTypestring

Legacy upload protocol for media (e.g. "media", "multipart").

Request body

Enter the body as JSON in the step's Body field.

labelsobject

Labels associated with this write request.

streamIdstring

The ID of the write stream to resume. This may only be set in the first message. When left empty, a new write stream will be created.

streamTokenstring (byte)

A stream token that was previously sent by the server. The client should set this field to the token from the most recent WriteResponse it has received. This acknowledges that the client has received responses up to this token. After sending this token, earlier tokens may not be used anymore. The server may close the stream if there are too many unacknowledged responses. Leave this field unset when creating a new stream. To resume a stream at a specific point, set this field and the `stream_id` field. Leave this field unset when creating a new stream.

writesarray<object>

The writes to apply. Always executed atomically and in order. This must be empty on the first request. This may be empty on the last request. This must not be empty on all other requests.

currentDocumentobject2 fields

A precondition on a document, used for conditional operations.

deletestring

A document name to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.

transformobject2 fields

A transformation of a document.

updateobject4 fields

A Firestore document. Must not exceed 1 MiB - 4 bytes.

updateMaskobject1 fields

A set of field paths on a document. Used to restrict a get or update operation on a document to a subset of its fields. This is different from standard field masks, as this is always scoped to a Document, and takes in account the dynamic nature of Value.

updateTransformsarray<object>7 fields

The transforms to perform after update. This field can be set only when the operation is `update`. If present, this write is equivalent to performing `update` and `transform` to the same document atomically and in order.

json
{
  "labels": {},
  "streamId": "string",
  "streamToken": "string",
  "writes": [
    {
      "currentDocument": {
        "exists": false,
        "updateTime": "string"
      },
      "delete": "string",
      "transform": {
        "document": "string",
        "fieldTransforms": [
          {
            "appendMissingElements": {
              "values": null
            },
            "fieldPath": "string",
            "increment": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "maximum": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "minimum": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "removeAllFromArray": {
              "values": null
            },
            "setToServerValue": "SERVER_VALUE_UNSPECIFIED"
          }
        ]
      },
      "update": {
        "createTime": "string",
        "fields": {},
        "name": "string",
        "updateTime": "string"
      },
      "updateMask": {
        "fieldPaths": [
          "string"
        ]
      },
      "updateTransforms": [
        {
          "appendMissingElements": {
            "values": [
              null
            ]
          },
          "fieldPath": "string",
          "increment": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "maximum": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "minimum": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "removeAllFromArray": {
            "values": [
              null
            ]
          },
          "setToServerValue": "SERVER_VALUE_UNSPECIFIED"
        }
      ]
    }
  ]
}

Response

Returns 200 with an object. Read it in later steps with {{firestoreProjectsDatabasesDocumentsWrite.response.data.<field>}}.

commitTimestring (google-datetime)

The time at which the commit occurred. Any read with an equal or greater `read_time` is guaranteed to see the effects of the write.

streamIdstring

The ID of the stream. Only set on the first message, when a new stream was created.

streamTokenstring (byte)

A token that represents the position of this response in the stream. This can be used by a client to resume the stream at this point. This field is always set.

writeResultsarray<object>

The result of applying the writes. This i-th write result corresponds to the i-th write in the request.

transformResultsarray<object>11 fields

The results of applying each DocumentTransform.FieldTransform, in the same order.

updateTimestring (google-datetime)

The last update time of the document after applying the write. Not set after a `delete`. If the write did not actually change the document, this will be the previous update_time.

json
{
  "commitTime": "string",
  "streamId": "string",
  "streamToken": "string",
  "writeResults": [
    {
      "transformResults": [
        {
          "arrayValue": {
            "values": [
              null
            ]
          },
          "booleanValue": false,
          "bytesValue": "string",
          "doubleValue": 0,
          "geoPointValue": {
            "latitude": 0,
            "longitude": 0
          },
          "integerValue": "string",
          "mapValue": {
            "fields": {}
          },
          "nullValue": "NULL_VALUE",
          "referenceValue": "string",
          "stringValue": "string",
          "timestampValue": "string"
        }
      ],
      "updateTime": "string"
    }
  ]
}

Need more? See the Firestore guide for connection setup and behaviour shared by every action.