Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aozarov committed Feb 18, 2015
2 parents 2f3be49 + 030713d commit 6ebd7d3
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,28 @@ consistency for all other queries.
Follow the [activation instructions][cloud-datastore-activation] to use the Google
Cloud Datastore API with your project.

import com.google.gcloud.datastore.DatastoreService;
import com.google.gcloud.datastore.DatastoreServiceFactory;
import com.google.gcloud.datastore.DatastoreServiceOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build();
DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
KeyFactory keyFactory = new KeyFactory(datastore).kind("...");
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);
if (entity == null) {
entity = Entity.builder(key)
.set("name", "John Do")
.set("age", 30)
.set("updated", false)
.build();
datastore.put(entity);
}
```java
import com.google.gcloud.datastore.DatastoreService;
import com.google.gcloud.datastore.DatastoreServiceFactory;
import com.google.gcloud.datastore.DatastoreServiceOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory;

DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build();
DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
KeyFactory keyFactory = new KeyFactory(datastore).kind("...");
Key key = keyFactory.newKey(keyName);
Entity entity = datastore.get(key);
if (entity == null) {
entity = Entity.builder(key)
.set("name", "John Do")
.set("age", 30)
.set("updated", false)
.build();
datastore.put(entity);
}
```

## Contributing

Expand Down

0 comments on commit 6ebd7d3

Please sign in to comment.