# Interface DatastoreWriter (3.1.0)

3.1.0 (latest) 2.40.0 2.37.0 2.36.0 2.34.0 2.33.3 2.32.3 2.31.4 2.30.0 2.29.1 2.28.2 2.27.1 2.26.4 2.25.2 2.24.3 2.23.0 2.22.0 2.21.3 2.20.2 2.19.2 2.18.5 2.17.6

    public interface DatastoreWriter

An interface to represent Google Cloud Datastore write operations.

## Methods

### add(FullEntity\<?\> entity)

    public abstract Entity add(FullEntity<?> entity)

Datastore add operation: inserts the provided entity. This method will automatically allocate
an id if necessary.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `entity` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.FullEntity<?>` the entity to add |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Entity` | an `Entity` with the same properties and a key that is either newly allocated or the same one if key is already complete |

### add(FullEntity\<?\>\[\] entities)

    public abstract List<Entity> add(FullEntity<?>[] entities)

Datastore add operation: inserts the provided entities. This method will automatically allocate
id for any entity with an incomplete key.
See Also: [#add(FullEntity)](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreWriter#com_google_cloud_datastore_DatastoreWriter_add_com_google_cloud_datastore_FullEntity____)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `entities` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.FullEntity<?>[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Entity>` | a list of `Entity` ordered by input with the same properties and a key that is either newly allocated or the same one if was already complete |

### delete(Key\[\] keys)

    public abstract void delete(Key[] keys)

A datastore delete operation. It is OK to request the deletion of a non-existing key.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `keys` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Key[]` |

### put(FullEntity\<?\> entity)

    public abstract Entity put(FullEntity<?> entity)

A Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it
otherwise. This method will automatically allocate an id if necessary.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `entity` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.FullEntity<?>` the entity to put |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Entity` | an `Entity` with the same properties and a key that is either newly allocated or the same one if key is already complete |

### put(FullEntity\<?\>\[\] entities)

    public abstract List<Entity> put(FullEntity<?>[] entities)

A Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it
otherwise. This method will automatically allocate id for any entity with an incomplete key.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `entities` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.FullEntity<?>[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Entity>` | a list of updated or inserted `Entity`, ordered by input. Returned keys are either newly allocated or the same one if was already complete. |

### update(Entity\[\] entities)

    public abstract void update(Entity[] entities)

A Datastore update operation. The operation will fail if an entity with the same key does not
already exist.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `entities` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.Entity[]` |