[英]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. 我正在开发一个appengine项目并使用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 https://cloud.google.com/appengine/docs/java/datastore/retrieving-query-results
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(q);
PreparedQuery pq = datastore.prepare(q); Entity result = pq.asSingleEntity();
实体结果= pq.asSingleEntity();
However, in this example to store data, they use 但是,在这个例子中存储数据,他们使用
com.google.cloud.datastore
com.google.cloud.datastore
https://cloud.google.com/datastore/docs/concepts/entities 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();
实体任务= 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.
但是,我正在寻找一种方法来删除其中一个。
com.google.appengine.api.datastore
- is specifically designed to work from Apps deployed on AppEngine. com.google.appengine.api.datastore
- 专门设计用于在AppEngine上部署的应用程序。 The API does not work if you later decide to deploy your App elsewhere (eg Compute Engine). 如果您以后决定在其他地方部署您的应用程序(例如,计算引擎),则API不起作用。
com.google.cloud.datastore
- is the new API that allows you to access Datastore from Apps deployed anywhere, not just AppEngine. com.google.cloud.datastore
- 是一种新的API,允许您从任何地方部署的应用程序访问数据存储,而不仅仅是AppEngine。
com.google.appengine.api.datastore
- has some additional features that the other one does not have (at least not yet). com.google.appengine.api.datastore
- 有一些额外的功能,另一个没有(至少还没有)。 For example, OR
condition in your Datastore queries, ability to integrate with other AppEngine Services such as MemCache, FullText Search, etc. 例如,数据存储区查询中的
OR
条件,与MemCache,FullText Search等其他AppEngine服务集成的能力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.