How to get the number of rows in a table in a Datastore?

后端 未结 3 1478
故里飘歌
故里飘歌 2020-12-31 21:31

In many cases, it could be useful to know the number of rows in a table (a kind) in a datastore using Google Application Engine.
There is not clear and fast solution . A

3条回答
  •  失恋的感觉
    2020-12-31 21:54

    You can count no. of rows in Google App Engine using com.google.appengine.api.datastore.Query as follow:

       int count;   
       Query qry=new Query("EmpEntity");   
       DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
       count=datastoreService.prepare(qry).countEntities(FetchOptions.Builder.withDefaults());
    

提交回复
热议问题