Go + App Engine数据存储区:如何过滤出为空的行?

Go + App Engine数据存储区:如何过滤出为空的行?

问题描述:

How do I filter out rows that are null? I know it's hard to find only-null rows, but hopefully this should be easier.

I'd like to do the following:

q := datastore.NewQuery("MY_KIND").Filter("MY_ID !=", nil)

... but Filter doesn't support the != comparator. FYI, using this GQL syntax in the Datastore Viewer works just fine:

SELECT * FROM MY_KIND WHERE MY_ID != NULL

如何过滤掉为空的行? 我知道很难找到仅空的行,但是希望这会更容易。 p>

我想执行以下操作: p>

  q:= datastore.NewQuery(“ MY_KIND”)。Filter(“ MY_ID!=”,nil)
  code>  pre> 
 
 

...但不支持Filter !=比较器。 仅供参考,在Datastore Viewer中使用此GQL语法可以正常工作: p>

  SELECT * FROM MY_KIND WHERE MY_ID!= NULL 
  code>  pre> 
 

You can use greater filter with the appropriate value (> 0 for numbers, > "" for strings).

Typically an ID cannot be an empty string or zero.