com.google.cloud.datastore.package-info Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of google-cloud-datastore Show documentation
Show all versions of google-cloud-datastore Show documentation
Java idiomatic client for Google Cloud Datastore.
/*
* Copyright 2015 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A client for Cloud Datastore – A highly-scalable NoSQL database for web and mobile applications.
*
* Here's a simple usage example for using google-cloud from App/Compute Engine. This example
* shows how to create a Datastore entity. For the complete source code see
* CreateEntity.java.
*
*
{@code
* Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
* KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
* Key key = keyFactory.newKey("keyName");
* Entity entity = Entity.newBuilder(key)
* .set("name", "John Doe")
* .set("age", 30)
* .set("access_time", Timestamp.now())
* .build();
* datastore.put(entity);
* }
*
* This second example shows how to get and update a Datastore entity if it exists. For the
* complete source code see
* UpdateEntity.java.
*
*
{@code
* Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
* KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
* Key key = keyFactory.newKey("keyName");
* Entity entity = datastore.get(key);
* if (entity != null) {
* System.out.println("Updating access_time for " + entity.getString("name"));
* entity = Entity.newBuilder(entity)
* .set("access_time", Timestamp.now())
* .build();
* datastore.update(entity);
* }
* }
*
* When using google-cloud from outside of App/Compute Engine, you have to specify a project
* ID and provide
* credentials.
*
* @see Google Cloud Datastore
*/
package com.google.cloud.datastore;