如何查询比较 GAE Datastore 上的两列?
How to make a query comparing two columns on GAE Datastore?
我有一个包含两列 gamesP1、gamesP2 的实体匹配。我如何查询 return 所有 gamesP1 > gamesP2 的实体?
数据存储查询过滤器 must be written 根据应用程序在查询时提供的值;他们不能引用其他属性的值。
根据您的数据模型,您可以定义另一个 属性、gamesDiff
,每当您更新实体时将其设置为 gamesP1 - gamesP2
。然后您可以将查询写为:
SELECT * FROM Match WHERE gamesDiff > 0
如果您使用的是 Python,请查看 ndb's ComputedProperty,这会让这一切变得简单。
我有一个包含两列 gamesP1、gamesP2 的实体匹配。我如何查询 return 所有 gamesP1 > gamesP2 的实体?
数据存储查询过滤器 must be written 根据应用程序在查询时提供的值;他们不能引用其他属性的值。
根据您的数据模型,您可以定义另一个 属性、gamesDiff
,每当您更新实体时将其设置为 gamesP1 - gamesP2
。然后您可以将查询写为:
SELECT * FROM Match WHERE gamesDiff > 0
如果您使用的是 Python,请查看 ndb's ComputedProperty,这会让这一切变得简单。