執行投影查詢在1.7版本NDB得到支持投影查詢,documentation states這是語法:如何NDB在GAE
qry = Article.query(projection=[Article.author, Article.tags])
但經營這導致例外:
TypeError: __init__() got an unexpected keyword argument 'projection'
那麼在NDB中是否有對投影查詢的支持,如果有,如何使用它?
執行投影查詢在1.7版本NDB得到支持投影查詢,documentation states這是語法:如何NDB在GAE
qry = Article.query(projection=[Article.author, Article.tags])
但經營這導致例外:
TypeError: __init__() got an unexpected keyword argument 'projection'
那麼在NDB中是否有對投影查詢的支持,如果有,如何使用它?
還有就是文檔中的錯誤,正確的語法是:只要需要**q_options參數
qry = Article.query().get(projection=[Article.author, Article.tags])
...取代get
與method of your choosing。
你可以找到如何從測試的情況下使用: http://codereview.appspot.com/6133044/patch/2001/1012
這裏:http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=181
但要記住 Article.query().get(projection=[Article.author, Article.tags])
總是返回實體,無法查詢。除了get
,您可以使用fetch(projection=[Article.author, Article.tags])
或fetch_async(projection=[Article.author, Article.tags])