简体   繁体   English

Google App Engine数据存储区不支持运算符+

[英]Google App Engine datastore does not support operator +

I'm playing with GAE, and need to make a query with something like this: 我正在玩GAE,并且需要使用类似以下内容的查询:

select from models.Post as p where (p.votesUp + p.votesDown > 10)

But I get this error: App Engine datastore does not support operator + 但是我收到此错误: App Engine数据存储区不支持运算符+

Which could be a good approach to replace that query? 哪种方法可以替换该查询?

The obvious thing that leaps out at me is to put a method on p that has a p.netVotes and query on that. 显而易见的事情是在p上放置一个具有p.netVotes的方法并对其进行查询。

But I'm not familiar enough with App Engine (I just started looking at it) to be sure that that works. 但是我对App Engine不够熟悉(我刚刚开始研究它),以确保它能正常工作。

This sounds similar to the issue with counters in app engine . 这听起来类似于App Engine中的计数器问题。 The simplest solution off the top of my head is to add a votesTotal attribute that is updated every time votesUp and votesDown is updated. 最简单的方法是添加一个votesTotal属性,该属性在每次votesUp和votesDown更新时都会更新。 Thus there's no large computation when you query for votesTotal > foo_val. 因此,当您查询votesTotal> foo_val时,无需进行大量计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM