File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
src/main/java/in/kuros/jfirebase Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1212
1313 <groupId >in.kuros</groupId >
1414 <artifactId >jFirebase</artifactId >
15- <version >1.3.1 </version >
15+ <version >1.3.2 </version >
1616
1717
1818 <description >This project aims at building a wrapper over nosql technologies - Firebase</description >
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public interface PersistenceService {
4545
4646 List <WriteResult > writeInBatch (Consumer <WriteBatch > batchConsumer );
4747
48+ <T > long count (Query <T > query );
49+
4850 static void init () {
4951 }
5052}
Original file line number Diff line number Diff line change @@ -278,6 +278,17 @@ public List<WriteResult> writeInBatch(final Consumer<WriteBatch> batchConsumer)
278278 }
279279 }
280280
281+ @ Override
282+ public <T > long count (Query <T > query ) {
283+ try {
284+ AggregateQuery aggregateQuery = QueryAdapter .toFirebaseQuery (firestore , query ).count ();
285+ final ApiFuture <AggregateQuerySnapshot > querySnapshot = aggregateQuery .get ();
286+ return querySnapshot .get ().getCount ();
287+ } catch (final Exception e ) {
288+ throw new PersistenceException (e );
289+ }
290+ }
291+
281292 @ SuppressWarnings ("unchecked" )
282293 private <T > Class <T > getClass (final T entity ) {
283294 return (Class <T >) entity .getClass ();
You can’t perform that action at this time.
0 commit comments