Python 云NDB中基于密钥的查询
我猜这很简单,但我很难把它做好。我成功地创建了该类型的多个实体Python 云NDB中基于密钥的查询,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,我猜这很简单,但我很难把它做好。我成功地创建了该类型的多个实体 class Word(ndb.Model): name = ndb.StringProperty(required=True) definition = ndb.StringProperty(required=True) 现在我想以最有效的方式查询特定的实体。所以我在做什么 with client.context(): ans = Word.query(ndb.Key(“Word”,”love”)).get()
class Word(ndb.Model):
name = ndb.StringProperty(required=True)
definition = ndb.StringProperty(required=True)
现在我想以最有效的方式查询特定的实体。所以我在做什么
with client.context():
ans = Word.query(ndb.Key(“Word”,”love”)).get()
但我犯了个错误
File "/layers/google.python.pip/pip/lib/python3.7/site-packages/google/cloud/ndb/query.py", line 1531, in filter
"Cannot filter a non-Node argument; received %r" % filter
TypeError: Cannot filter a non-Node argument; received Key(‘Word’, ‘love’)”
我查看我的数据存储,发现单词就在那里。我怎样才能成功地做到这一点呢?事实证明,我所要做的就是
with client.context():
ans = ndb.Key(“Word”,”love”).get()