无法过滤非节点参数 - 数据存储区 - 谷歌应用引擎 - python

Kri*_*nya 8 python google-app-engine google-cloud-datastore

Class user(ndb.Model):
  def post(self):
    name = db.StringProperty()
    age = db.StringProperty()
Class search(webapp2.RequestHandler):
  def post(self):
    x = userData.query().filter("age >=",1)  #error points to this line
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:无法过滤非Node参数; 收到'年龄> ='

我遵循https://developers.google.com/appengine/docs/python/datastore/queries中提到的语法

请让我知道如何解决此问题.

Kri*_*nya 12

我终于在
Google App Engine(python)上找到了答案:根据自定义字段过滤用户.
有关此文档,请参阅https://developers.google.com/appengine/docs/python/ndb/queries#properties_by_string

Model类中定义的属性必须引用为ndb.GenericProperty().对于问题中提到的代码,过滤器语法应为:

x = userData.query().filter(ndb.GenericProperty("age") >= 1).get()
Run Code Online (Sandbox Code Playgroud)