10

How do I get the equivalent result of the following query in NDB?

Entity.all(keys_only=True).fetch(20)

I know you can pass 'keys_only=True' to the iter() method. But what if I want to perform a keys only fetch, how do I do that in NDB?

Albert
  • 3,611
  • 3
  • 28
  • 52

1 Answers1

14

Found it in the GAE NDB Docs. The answer is Entity.query().fetch(20,keys_only=True).

Albert
  • 3,611
  • 3
  • 28
  • 52
  • 8
    Also check the "cheat sheet": https://docs.google.com/document/d/1AefylbadN456_Z7BZOpZEXDq8cR8LYu7QgI7bt5V0Iw/edit?pli=1 -- It is really a conversion guide from db to ndb. – Guido van Rossum Apr 19 '12 at 04:56
  • 1
    Cool! Thanks for this! It took me a while to find the solution in the official docs, and it's not the same implementation as DB. Perhaps this could also be added to the cheat sheet. :) – Albert Apr 19 '12 at 05:37