Datastore add operation: inserts the provided entities. This method will automatically allocate
id for any entity with an incomplete key.
See Also: #add(FullEntity)
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Interface DatastoreWriter (2.31.2)\n\nVersion latestkeyboard_arrow_down\n\n- [2.31.2 (latest)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreWriter)\n- [2.31.1](/java/docs/reference/google-cloud-datastore/2.31.1/com.google.cloud.datastore.DatastoreWriter)\n- [2.30.0](/java/docs/reference/google-cloud-datastore/2.30.0/com.google.cloud.datastore.DatastoreWriter)\n- [2.29.1](/java/docs/reference/google-cloud-datastore/2.29.1/com.google.cloud.datastore.DatastoreWriter)\n- [2.28.2](/java/docs/reference/google-cloud-datastore/2.28.2/com.google.cloud.datastore.DatastoreWriter)\n- [2.27.1](/java/docs/reference/google-cloud-datastore/2.27.1/com.google.cloud.datastore.DatastoreWriter)\n- [2.26.4](/java/docs/reference/google-cloud-datastore/2.26.4/com.google.cloud.datastore.DatastoreWriter)\n- [2.25.2](/java/docs/reference/google-cloud-datastore/2.25.2/com.google.cloud.datastore.DatastoreWriter)\n- [2.24.3](/java/docs/reference/google-cloud-datastore/2.24.3/com.google.cloud.datastore.DatastoreWriter)\n- [2.23.0](/java/docs/reference/google-cloud-datastore/2.23.0/com.google.cloud.datastore.DatastoreWriter)\n- [2.22.0](/java/docs/reference/google-cloud-datastore/2.22.0/com.google.cloud.datastore.DatastoreWriter)\n- [2.21.3](/java/docs/reference/google-cloud-datastore/2.21.3/com.google.cloud.datastore.DatastoreWriter)\n- [2.20.2](/java/docs/reference/google-cloud-datastore/2.20.2/com.google.cloud.datastore.DatastoreWriter)\n- [2.19.2](/java/docs/reference/google-cloud-datastore/2.19.2/com.google.cloud.datastore.DatastoreWriter)\n- [2.18.5](/java/docs/reference/google-cloud-datastore/2.18.5/com.google.cloud.datastore.DatastoreWriter)\n- [2.17.6](/java/docs/reference/google-cloud-datastore/2.17.6/com.google.cloud.datastore.DatastoreWriter) \n\n public interface DatastoreWriter\n\nAn interface to represent Google Cloud Datastore write operations.\n\nMethods\n-------\n\n### add(FullEntity\\\u003c?\\\u003e entity)\n\n public abstract Entity add(FullEntity\u003c?\u003e entity)\n\nDatastore add operation: inserts the provided entity. This method will automatically allocate\nan id if necessary.\n\n### add(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public abstract List\u003cEntity\u003e add(FullEntity\u003c?\u003e[] entities)\n\nDatastore add operation: inserts the provided entities. This method will automatically allocate\nid for any entity with an incomplete key.\nSee Also: [#add(FullEntity)](/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.DatastoreWriter#com_google_cloud_datastore_DatastoreWriter_add_com_google_cloud_datastore_FullEntity____)\n\n### delete(Key\\[\\] keys)\n\n public abstract void delete(Key[] keys)\n\nA datastore delete operation. It is OK to request the deletion of a non-existing key.\n\n### put(FullEntity\\\u003c?\\\u003e entity)\n\n public abstract Entity put(FullEntity\u003c?\u003e entity)\n\nA Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it\notherwise. This method will automatically allocate an id if necessary.\n\n### put(FullEntity\\\u003c?\\\u003e\\[\\] entities)\n\n public abstract List\u003cEntity\u003e put(FullEntity\u003c?\u003e[] entities)\n\nA Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it\notherwise. This method will automatically allocate id for any entity with an incomplete key.\n\n### update(Entity\\[\\] entities)\n\n public abstract void update(Entity[] entities)\n\nA Datastore update operation. The operation will fail if an entity with the same key does not\nalready exist."]]