Java Code Examples for com.google.cloud.datastore.Datastore#delete()

The following examples show how to use com.google.cloud.datastore.Datastore#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java    From java-docs-samples with Apache License 2.0 6 votes vote down vote up
public static void wipeDatastore() {
  Datastore datastore = getDatastore();
  QueryResults<Key> guestbooks =
      datastore.run(Query.newKeyQueryBuilder().setKind("Greeting").build());
  ArrayList<Key> keys = Lists.newArrayList(guestbooks);

  if (!keys.isEmpty()) {
    datastore.delete(keys.toArray(new Key[keys.size()]));
  }
}
 
Example 2
Source File: QuickstartSampleIT.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static final void deleteTestEntity() {
  Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
  String kind = "Task";
  String name = "sampletask1";
  Key taskKey = datastore.newKeyFactory().setKind(kind).newKey(name);
  datastore.delete(taskKey);
}