Can you get all entities of a model in appengine and not a gqlquery

大兔子大兔子 提交于 2019-12-13 18:03:30

问题


I want a list of all my model entities. Model.all() returns a gqlquery. I know that I can then do list comprehension on the query and end up with the result I am seeking. Is there not a way already built-in saving the additional step of doing the comprehension?

Or is everyone just subclassing and building the method in themselves? ... or is this a safety measure preventing us from accessing more data then we intended incurring costs?

Thanks


回答1:


To get to the entity you need a key. If you only have a kind of the entity, then GAE needs to go through indexes to find all keys, e.g. it uses Metadata Queries.

Metadata queries give you the option to query by namespace, kind and property.




回答2:


you have 2 options:

  • use fetch() and get a defined number of entities like Model.all().fetch(100)
  • use Model.all() and loop over the query.


来源:https://stackoverflow.com/questions/9824317/can-you-get-all-entities-of-a-model-in-appengine-and-not-a-gqlquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!