def delete_multi(keys, connection=None, dataset_id=None): """Delete the keys in the Cloud Datastore. :type keys: list of :class:`gcloud.datastore.key.Key` :param keys: The keys to be deleted from the datastore. :type connection: :class:`gcloud.datastore.connection.Connection` :param connection: Optional connection used to connect to datastore. If not passed, inferred from the environment. :type dataset_id: :class:`gcloud.datastore.connection.Connection` :param dataset_id: Optional. The dataset ID used to connect to datastore. If not passed, inferred from the environment. :raises: EnvironmentError if ``connection`` or ``dataset_id`` not passed, and cannot be inferred from the environment. ValueError if one or more keys has a dataset ID not matching the passed / inferred dataset ID. """ if not keys: return connection = _require_connection(connection) dataset_id = _require_dataset_id(dataset_id, keys[0]) # We allow partial keys to attempt a delete, the backend will fail. current = Batch.current() in_batch = current is not None if not in_batch: current = Batch(dataset_id=dataset_id, connection=connection) for key in keys: current.delete(key) if not in_batch: current.commit()
def delete(keys, connection=None, dataset_id=None): """Delete the keys in the Cloud Datastore. :type keys: list of :class:`gcloud.datastore.key.Key` :param keys: The keys to be deleted from the datastore. :type connection: :class:`gcloud.datastore.connection.Connection` :param connection: Optional connection used to connect to datastore. If not passed, inferred from the environment. :type dataset_id: :class:`gcloud.datastore.connection.Connection` :param dataset_id: Optional. The dataset ID used to connect to datastore. If not passed, inferred from the environment. :raises: EnvironmentError if ``connection`` or ``dataset_id`` not passed, and cannot be inferred from the environment. ValueError if one or more keys has a dataset ID not matching the passed / inferred dataset ID. """ if not keys: return connection = _require_connection(connection) dataset_id = _require_dataset_id(dataset_id, keys[0]) # We allow partial keys to attempt a delete, the backend will fail. current = Batch.current() in_batch = current is not None if not in_batch: current = Batch(dataset_id=dataset_id, connection=connection) for key in keys: current.delete(key) if not in_batch: current.commit()
def delete(keys, connection=None): """Delete the keys in the Cloud Datastore. :type keys: list of :class:`gcloud.datastore.key.Key` :param keys: The keys to be deleted from the datastore. :type connection: :class:`gcloud.datastore.connection.Connection` :param connection: Optional connection used to connect to datastore. """ if not keys: return connection = connection or _implicit_environ.CONNECTION # We allow partial keys to attempt a delete, the backend will fail. current = Batch.current() in_batch = current is not None if not in_batch: dataset_id = _get_dataset_id_from_keys(keys) current = Batch(dataset_id=dataset_id, connection=connection) for key in keys: current.delete(key) if not in_batch: current.commit()