Can you get all entities of a model in appengine a

2019-08-12 13:31发布

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

2条回答
ゆ 、 Hurt°
2楼-- · 2019-08-12 13:48

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.

查看更多
The star\"
3楼-- · 2019-08-12 13:59

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.
查看更多
登录 后发表回答