Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between libraries appengine.api.datastore and com.google.cloud.datastore?

I am developing an appengine project and storing my data using Google Datastore. I am using different Datastore libraries as they are the ones used in the examples, but I find it kind of weird that I have to use both:

If I check the docs for querying, in this example they use this library to process queries:

com.google.appengine.api.datastore

https://cloud.google.com/appengine/docs/java/datastore/retrieving-query-results

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(q); Entity result = pq.asSingleEntity();

However, in this example to store data, they use

com.google.cloud.datastore

https://cloud.google.com/datastore/docs/concepts/entities

Entity task = Entity.builder(taskKey) .set("category", "Personal") .set("done", false) .set("priority", 4) .set("description", "Learn Cloud Datastore") .build();

Right now I am able to use both but I am wondering which one is better for which kind of purpose or if they are just the same libraries with different packages. However, I am looking for a way to remove one of them.

like image 280
Javier Delgado Avatar asked Nov 27 '16 16:11

Javier Delgado


People also ask

What type of database is Google Datastore?

Datastore is a highly scalable NoSQL database for your web and mobile applications.

What is Google App Datastore?

Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. Datastore features include: Atomic transactions. Datastore can execute a set of operations where either all succeed, or none occur.


1 Answers

com.google.appengine.api.datastore - is specifically designed to work from Apps deployed on AppEngine. The API does not work if you later decide to deploy your App elsewhere (e.g. Compute Engine).

com.google.cloud.datastore - is the new API that allows you to access Datastore from Apps deployed anywhere, not just AppEngine.

com.google.appengine.api.datastore - has some additional features that the other one does not have (at least not yet). For example, OR condition in your Datastore queries, ability to integrate with other AppEngine Services such as MemCache, FullText Search, etc.

like image 129
Sai Pullabhotla Avatar answered Oct 17 '22 02:10

Sai Pullabhotla