Python 如何在ReferenceProperty';你想工作吗?
我正在尝试使用引用实体中的查询集合_集进行筛选和获取,如下所示:Python 如何在ReferenceProperty';你想工作吗?,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,我正在尝试使用引用实体中的查询集合_集进行筛选和获取,如下所示: class Author (db.Model) name = db.StringProperty() class Book (db.Model) author = db.ReferenceProperty (collection_name="books", indexed=True) name = db.StringProperty() author = Author.get (author_key) q =
class Author (db.Model)
name = db.StringProperty()
class Book (db.Model)
author = db.ReferenceProperty (collection_name="books", indexed=True)
name = db.StringProperty()
author = Author.get (author_key)
q = author.books
q.filter ("name =", "BOOK_NAME")
books = q.fetch(5)
我不是为了还书才拿到这个的。以及以下工作:
author = Author.get (author_key)
q = Book.all()
q.filter ("author =", author.key())
q.filter ("name =", "BOOK_NAME")
books = q.fetch(5)
那么前者应该有效吗
另外,推荐的最佳实践是什么?使用authors集合集合或使用author.key()的筛选器
谢谢。我想你想要的是
对象。filter(field=“value”)
不是对象。filter(“field=”,some\u value)
在这种情况下“objects”不是db.Query类实例吗?在其他情况下,此“q.filter”(“field=”,value)”有效:(谢谢)