1

I m using the low-level API in the App Engine Datastore . To retrieve an entity I use

Entity post = datastore.get(postKey);

but this code will return only the post with this postkey. What shall i do if i want to return all the posts ?

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
user2528061
  • 47
  • 2
  • 5
  • did you checked this: http://stackoverflow.com/questions/9824317/can-you-get-all-entities-of-a-model-in-appengine-and-not-a-gqlquery or http://stackoverflow.com/a/6529915/529543 , did you searched in your seach engine?? –  Jun 27 '13 at 16:00
  • possible duplicate of [How to list kinds in datastore?](http://stackoverflow.com/questions/2541945/how-to-list-kinds-in-datastore) – mimming Jun 27 '13 at 17:58

1 Answers1

3

you need todo a query, not a get,

get ist just a single instance by id, query is result of your query.

just do:

// Use class Query to assemble a query
Query q = new Query("Post");

// Use PreparedQuery interface to retrieve results
PreparedQuery pq = datastore.prepare(q);


for (Entity result : pq.asIterable()) {
  String postName = (String) result.getProperty("PostName");
}
fmt.Println.MKO
  • 2,065
  • 1
  • 17
  • 25