如何过滤列表中是否存在数据存储 属性

How to filter whether datastore property is present in list or not

此查询是用 JDO 编写的,我在其中根据国家/地区过滤用户。 联系人 种类有 属性 国家/地区。仅获取其国家/地区出现在以下列表中的那些用户。

List<String> countryList = Arrays.asList("USA","India","France");



SELECT FROM Contacts WHERE :countryList.contains(country) && loginType == 'Google' && dateAdded >= 0 && dateAdded <= 1567078411000 ORDER BY dateAdded DESC RANGE 0,30

如何在低级数据存储中编写上述查询的代码?

虽然这不是推荐的解决方案,因为在迁移到较新的 App Engine 运行时之前需要升级到推荐的 API,但您可以使用 Java App Engine API client 执行此类“WHERE IN”查询.就像下面的例子:

List<String> countryList = Arrays.asList("USA","India","France");

Filter propertyFilter =
        new FilterPredicate("height", FilterOperator.IN, countryList);
Query q = new Query("Contacts").setFilter(propertyFilter);

Datastore Client Library for Java, however, and I believe it is because, under the hood, Datastore translates this query into individual queries for each element on the list. Like explained in this post 不支持。