如何在谷歌App Engine中存储数据

时间:2012-09-05 08:08:25

标签: google-app-engine

我是Google App Engine的新用户,我正在阅读此页面: https://developers.google.com/appengine/docs/java/datastore/queries

这里他们已经解释了如何从dataStore中检索数据:

  // Get the Datastore Service
   DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

      // The Query interface assembles a query
Query q = new Query("Person");

   //Use CompositeFilter to set more than one filter
    q.setFilter(CompositeFilterOperator.and(
 new FilterPredicate("lastName", Query.FilterOperator.EQUAL, lastNameParam),
 new FilterPredicate("height", Query.FilterOperator.LESS_THAN, maxHeightParam)));


    // PreparedQuery contains the methods for fetching query results
   // from the Datastore
    PreparedQuery pq = datastore.prepare(q);

  for (Entity result : pq.asIterable()) {
  String firstName = (String) result.getProperty("firstName");
   String lastName = (String) result.getProperty("lastName");
   Long height = (Long) result.getProperty("height");
   System.out.println(firstName + " " + lastName + ", " + height + " inches tall");
  }

但是如何保存这些data.where以及如何在DataStore中保存firstName和LastName?

由于

1 个答案:

答案 0 :(得分:0)

您是否考虑过阅读其他一些文档,例如在that explains exactly what to do之上链接的文档?