예제 #1
0
    def delete(self, option=None) -> Any:
        """Delete the current document in the Firestore database.

        Args:
            option (Optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
                A write option to make assertions / preconditions on the server
                state of the document before applying changes.

        Returns:
            :class:`google.protobuf.timestamp_pb2.Timestamp`:
            The time that the delete request was received by the server.
            If the document did not exist when the delete was sent (i.e.
            nothing was deleted), this method will still succeed and will
            still return the time that the request was received by the server.
        """
        write_pb = _helpers.pb_for_delete(self._document_path, option)
        commit_response = self._client._firestore_api.commit(
            request={
                "database": self._client._database_string,
                "writes": [write_pb],
                "transaction": None,
            },
            metadata=self._client._rpc_metadata,
        )

        return commit_response.commit_time
    def _prep_delete(
        self,
        option: _helpers.WriteOption = None,
        retry: retries.Retry = None,
        timeout: float = None,
    ) -> Tuple[dict, dict]:
        """Shared setup for async/sync :meth:`delete`."""
        write_pb = _helpers.pb_for_delete(self._document_path, option)
        request = {
            "database": self._client._database_string,
            "writes": [write_pb],
            "transaction": None,
        }
        kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout)

        return request, kwargs
예제 #3
0
    def delete(self, reference, option=None) -> None:
        """Add a "change" to delete a document.

        See
        :meth:`google.cloud.firestore_v1.document.DocumentReference.delete`
        for more information on how ``option`` determines how the change is
        applied.

        Args:
            reference (:class:`~google.cloud.firestore_v1.document.DocumentReference`):
                A document reference that will be deleted in this batch.
            option (Optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
                A write option to make assertions / preconditions on the server
                state of the document before applying changes.
        """
        write_pb = _helpers.pb_for_delete(reference._document_path, option)
        self._add_write_pbs([write_pb])
예제 #4
0
    def delete(self, reference, option=None):
        """Add a "change" to delete a document.

        See
        :meth:`~.firestore_v1.document.DocumentReference.delete` for
        more information on how ``option`` determines how the change is
        applied.

        Args:
            reference (~.firestore_v1.document.DocumentReference): A
               document reference that will be deleted in this batch.
            option (Optional[~.firestore_v1.client.WriteOption]): A
               write option to make assertions / preconditions on the server
               state of the document before applying changes.
        """
        write_pb = _helpers.pb_for_delete(reference._document_path, option)
        self._add_write_pbs([write_pb])
예제 #5
0
    def delete(self, option=None):
        """Delete the current document in the Firestore database.

        Args:
            option (Optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
                A write option to make assertions / preconditions on the server
                state of the document before applying changes.

        Returns:
            :class:`google.protobuf.timestamp_pb2.Timestamp`:
            The time that the delete request was received by the server.
            If the document did not exist when the delete was sent (i.e.
            nothing was deleted), this method will still succeed and will
            still return the time that the request was received by the server.
        """
        write_pb = _helpers.pb_for_delete(self._document_path, option)
        commit_response = self._client._firestore_api.commit(
            self._client._database_string,
            [write_pb],
            transaction=None,
            metadata=self._client._rpc_metadata,
        )

        return commit_response.commit_time