google-app-engine - 如何使用objectify在谷歌数据存储上应用不同的?
问题描述
我正在尝试获取一些在属性上具有不同值的实体。比如说,我有一个名为消息的实体。它有一些属性,比如 personId、typeId、convId、createdTime 等。我想要获取具有不同 convIds 的 personId p1 的消息。我怎样才能做到这一点。
我已经提到 Executing DISTINCT query with objectify for app engine and some others。并尝试了这样的事情。
ofy().load().type(messages.class).limit( 10 ).filter("personId ==", "p1").order("-createdTime").project("convId").distinct(true).list();
我确信有一些实体具有这种组合。但它没有获取任何实体。请帮我解决一下这个。
解决方案
不幸的是,您的查询无效。对于投影查询,您需要distinct
使用您排序的值(即 -createdTime)。要使用 distinct,您需要按 convId 排序。
https://cloud.google.com/datastore/docs/concepts/queries#restrictions_on_queries有更多详细信息。
推荐阅读
- rest - 使用 Google 云服务帐户在 GKE 上验证 REST API
- java - 为什么不能将子类型值分配给泛型类型?
- spring-boot - 如何在端口 443 上运行 Spring Boot
- laravel - Laravel nova 和 belongsToThrough?
- angular - ion-input:检查 ionInput 上的输入并将焦点设置在下一个字段上
- mainframe - 使用 EXECIO 将 rexx 输出逻辑写入数据集?
- python - 命令错误退出状态 1:- Pytorch 对象检测
- python - 即使安装成功也无法导入sklearn
- eclipse - Eclipse Project Expoloer Active Highlite 颜色
- unreal-engine4 - UnrealEngine 4.26.0 (Preview2) 中的 MultiSphereTraceByChannel 问题