Skip to content

Commit b695d99

Browse files
authored
Revert "Public count (#10246)" (#10252)
This reverts commit 8aae6be.
1 parent 8aae6be commit b695d99

File tree

11 files changed

+54
-118
lines changed

11 files changed

+54
-118
lines changed

Firestore/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# Unreleased
2-
- [feature] Added `Query.count()`, which fetches the number of documents in the
3-
result set without actually downloading the documents (#10246).
42
- [fixed] Fixed compiler warning about `@param comparator` (#10226).
53

64
# 9.6.0

Firestore/Example/Tests/Integration/API/FIRCountTests.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#import <XCTest/XCTest.h>
2020

2121
#import "Firestore/Example/Tests/Util/FSTIntegrationTestCase.h"
22-
#import "Firestore/Source/Public/FirebaseFirestore/FIRAggregateQuery.h"
23-
#import "Firestore/Source/Public/FirebaseFirestore/FIRAggregateQuerySnapshot.h"
24-
#import "Firestore/Source/Public/FirebaseFirestore/FIRAggregateSource.h"
22+
#import "Firestore/Source/API/FIRAggregateQuery+Internal.h"
23+
#import "Firestore/Source/API/FIRAggregateQuerySnapshot+Internal.h"
24+
#import "Firestore/Source/API/FIRQuery+Internal.h"
2525

2626
@interface FIRCountTests : FSTIntegrationTestCase
2727
@end

Firestore/Source/API/FIRAggregateQuery+Internal.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,35 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "FIRAggregateQuery.h"
17+
// TODO(b/246760853): Move FIRAggregateQuery to public headers to release it.
18+
19+
#import "FIRAggregateSource+Internal.h"
1820
#import "FIRQuery.h"
1921

20-
@interface FIRAggregateQuery (/* init */)
22+
@class FIRAggregateQuerySnapshot;
23+
24+
/**
25+
* An `AggregateQuery` computes some aggregation statistics from the result set of a base
26+
* `Query`.
27+
*/
28+
NS_SWIFT_NAME(AggregateQuery)
29+
@interface FIRAggregateQuery : NSObject
2130

2231
- (instancetype _Nonnull)init NS_UNAVAILABLE;
2332
- (instancetype _Nonnull)initWithQuery:(FIRQuery *_Nonnull)query NS_DESIGNATED_INITIALIZER;
2433

34+
/** The base `Query` for this aggregate query. */
35+
@property(nonatomic, readonly) FIRQuery *_Nonnull query;
36+
37+
/**
38+
* Executes the aggregate query and reads back the results as a `FIRAggregateQuerySnapshot`.
39+
*
40+
* @param source indicates where the results should be fetched from.
41+
* @param completion a block to execute once the results have been successfully read.
42+
* snapshot will be `nil` only if error is `non-nil`.
43+
*/
44+
- (void)aggregationWithSource:(FIRAggregateSource)source
45+
completion:(void (^_Nonnull)(FIRAggregateQuerySnapshot *_Nullable snapshot,
46+
NSError *_Nullable error))completion
47+
NS_SWIFT_NAME(aggregation(source:completion:));
2548
@end

Firestore/Source/API/FIRAggregateQuerySnapshot+Internal.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,29 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "FIRAggregateQuerySnapshot.h"
17+
// TODO(b/246760853): Move FIRAggregateQuerySnapshot to public headers to release it.
18+
19+
#import "FIRAggregateQuery+Internal.h"
1820

1921
@class FIRAggregateQuery;
2022

21-
@interface FIRAggregateQuerySnapshot (/* init */)
23+
/**
24+
* An `AggregateQuerySnapshot` contains results of a `AggregateQuery`.
25+
*/
26+
NS_SWIFT_NAME(AggregateQuerySnapshot)
27+
@interface FIRAggregateQuerySnapshot : NSObject
2228

2329
- (instancetype _Nonnull)init NS_UNAVAILABLE;
2430
- (instancetype _Nonnull)initWithCount:(int64_t)result
2531
Query:(FIRAggregateQuery* _Nonnull)query NS_DESIGNATED_INITIALIZER;
2632

33+
/** The original `AggregateQuery` this snapshot is a result of. */
34+
@property(nonatomic, readonly) FIRAggregateQuery* _Nonnull query;
35+
36+
/**
37+
* The result of a document count aggregation. Null if no count aggregation is
38+
* available in the result.
39+
*/
40+
@property(nonatomic, readonly) NSNumber* _Nullable count;
41+
2742
@end

Firestore/Source/Public/FirebaseFirestore/FIRAggregateSource.h renamed to Firestore/Source/API/FIRAggregateSource+Internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import <Foundation/Foundation.h>
17+
// TODO(b/246760853): Move FIRAggregateSource to public headers to release it.
1818

19-
NS_ASSUME_NONNULL_BEGIN
19+
#import <Foundation/Foundation.h>
2020

2121
/** Configures the behavior of `AggregateQuery.aggregateWithSource(source:completion:)`. */
2222
typedef NS_ENUM(NSUInteger, FIRAggregateSource) {
@@ -28,5 +28,3 @@ typedef NS_ENUM(NSUInteger, FIRAggregateSource) {
2828
*/
2929
FIRAggregateSourceServer,
3030
} NS_SWIFT_NAME(AggregateSource);
31-
32-
NS_ASSUME_NONNULL_END

Firestore/Source/API/FIRQuery+Internal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#import "FIRAggregateQuery+Internal.h"
1718
#import "FIRQuery.h"
1819

1920
#include <memory>
@@ -47,6 +48,12 @@ NS_ASSUME_NONNULL_BEGIN
4748
// TODO(orquery): This method will become public API. Change visibility and add documentation.
4849
- (FIRQuery *)queryWhereFilter:(FIRFilter *)filter;
4950

51+
// TODO(b/246760853): This property will become public API.
52+
/**
53+
* An `AggregateQuery` counting the number of documents matching this query.
54+
*/
55+
@property(nonatomic, readonly) FIRAggregateQuery *count;
56+
5057
@end
5158

5259
NS_ASSUME_NONNULL_END

Firestore/Source/API/FIRQuery.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <utility>
2121
#include <vector>
2222

23-
#import "FIRAggregateQuery+Internal.h"
2423
#import "FIRDocumentReference.h"
2524
#import "FIRFirestoreErrors.h"
2625
#import "Firestore/Source/API/FIRDocumentReference+Internal.h"

Firestore/Source/Public/FirebaseFirestore/FIRAggregateQuery.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

Firestore/Source/Public/FirebaseFirestore/FIRAggregateQuerySnapshot.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

Firestore/Source/Public/FirebaseFirestore/FIRQuery.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import "FIRFirestoreSource.h"
2020
#import "FIRListenerRegistration.h"
2121

22-
@class FIRAggregateQuery;
2322
@class FIRFieldPath;
2423
@class FIRFirestore;
2524
@class FIRQuerySnapshot;
@@ -543,13 +542,6 @@ NS_SWIFT_NAME(Query)
543542
*/
544543
- (FIRQuery *)queryEndingAtValues:(NSArray *)fieldValues NS_SWIFT_NAME(end(at:));
545544

546-
#pragma mark - Aggregation
547-
548-
/**
549-
* An `AggregateQuery` counting the number of documents matching this query.
550-
*/
551-
@property(nonatomic, readonly) FIRAggregateQuery *count;
552-
553545
@end
554546

555547
NS_ASSUME_NONNULL_END

Firestore/Swift/Tests/Integration/AsyncAwaitIntegrationTests.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,5 @@ let emptyBundle = """
7373

7474
XCTAssertNil(value, "value should be nil on success")
7575
}
76-
77-
func testCount() async throws {
78-
let collection = collectionRef()
79-
try await collection.addDocument(data: [:])
80-
let snapshot = try await collection.count.getAggregation(source: .server)
81-
XCTAssertEqual(snapshot.count, 1)
82-
}
8376
}
8477
#endif

0 commit comments

Comments
 (0)