FIRQuery.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FIRFirestoreSource.h"
  18. #import "FIRListenerRegistration.h"
  19. @class FIRAggregateQuery;
  20. @class FIRAggregateField;
  21. @class FIRFieldPath;
  22. @class FIRFirestore;
  23. @class FIRFilter;
  24. @class FIRQuerySnapshot;
  25. @class FIRDocumentSnapshot;
  26. NS_ASSUME_NONNULL_BEGIN
  27. /**
  28. * A block type used to handle failable snapshot method callbacks.
  29. */
  30. typedef void (^FIRQuerySnapshotBlock)(FIRQuerySnapshot *_Nullable snapshot,
  31. NSError *_Nullable error)
  32. NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.");
  33. /**
  34. * A `Query` refers to a query which you can read or listen to. You can also construct
  35. * refined `Query` objects by adding filters and ordering.
  36. */
  37. NS_SWIFT_NAME(Query)
  38. @interface FIRQuery : NSObject
  39. /** :nodoc: */
  40. - (id)init __attribute__((unavailable("FIRQuery cannot be created directly.")));
  41. /** The `Firestore` instance that created this query (useful for performing transactions, etc.). */
  42. @property(nonatomic, strong, readonly) FIRFirestore *firestore;
  43. #pragma mark - Retrieving Data
  44. /**
  45. * Reads the documents matching this query.
  46. *
  47. * This method attempts to provide up-to-date data when possible by waiting for
  48. * data from the server, but it may return cached data or fail if you are
  49. * offline and the server cannot be reached. See the
  50. * `getDocuments(source:completion:)` method to change this behavior.
  51. *
  52. * @param completion a block to execute once the documents have been successfully read.
  53. * documentSet will be `nil` only if error is `non-nil`.
  54. */
  55. - (void)getDocumentsWithCompletion:
  56. (void (^)(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error))completion
  57. NS_SWIFT_NAME(getDocuments(completion:));
  58. /**
  59. * Reads the documents matching this query.
  60. *
  61. * @param source indicates whether the results should be fetched from the cache
  62. * only (`Source.cache`), the server only (`Source.server`), or to attempt
  63. * the server and fall back to the cache (`Source.default`).
  64. * @param completion a block to execute once the documents have been successfully read.
  65. * documentSet will be `nil` only if error is `non-nil`.
  66. */
  67. - (void)getDocumentsWithSource:(FIRFirestoreSource)source
  68. completion:(void (^)(FIRQuerySnapshot *_Nullable snapshot,
  69. NSError *_Nullable error))completion
  70. NS_SWIFT_NAME(getDocuments(source:completion:));
  71. /**
  72. * Attaches a listener for `QuerySnapshot` events.
  73. *
  74. * @param listener The listener to attach.
  75. *
  76. * @return A `ListenerRegistration` object that can be used to remove this listener.
  77. */
  78. - (id<FIRListenerRegistration>)addSnapshotListener:
  79. (void (^)(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error))listener
  80. NS_SWIFT_NAME(addSnapshotListener(_:));
  81. /**
  82. * Attaches a listener for `QuerySnapshot` events.
  83. *
  84. * @param includeMetadataChanges Whether metadata-only changes (i.e. only
  85. * `DocumentSnapshot.metadata` changed) should trigger snapshot events.
  86. * @param listener The listener to attach.
  87. *
  88. * @return A `ListenerRegistration` that can be used to remove this listener.
  89. */
  90. - (id<FIRListenerRegistration>)
  91. addSnapshotListenerWithIncludeMetadataChanges:(BOOL)includeMetadataChanges
  92. listener:(void (^)(FIRQuerySnapshot *_Nullable snapshot,
  93. NSError *_Nullable error))listener
  94. NS_SWIFT_NAME(addSnapshotListener(includeMetadataChanges:listener:));
  95. #pragma mark - Filtering Data
  96. /**
  97. * Creates and returns a new Query with the additional filter.
  98. *
  99. * @param filter The new filter to apply to the existing query.
  100. * @return The newly created Query.
  101. */
  102. - (FIRQuery *)queryWhereFilter:(FIRFilter *)filter NS_SWIFT_NAME(whereFilter(_:));
  103. /**
  104. * Creates and returns a new `Query` with the additional filter that documents must
  105. * contain the specified field and the value must be equal to the specified value.
  106. *
  107. * @param field The name of the field to compare.
  108. * @param value The value the field must be equal to.
  109. *
  110. * @return The created `Query`.
  111. */
  112. - (FIRQuery *)queryWhereField:(NSString *)field
  113. isEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isEqualTo:));
  114. /**
  115. * Creates and returns a new `Query` with the additional filter that documents must
  116. * contain the specified field and the value does not equal the specified value.
  117. *
  118. * @param path The path of the field to compare.
  119. * @param value The value the field must be equal to.
  120. *
  121. * @return The created `Query`.
  122. */
  123. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  124. isNotEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isNotEqualTo:));
  125. /**
  126. * Creates and returns a new `Query` with the additional filter that documents must
  127. * contain the specified field and the value does not equal the specified value.
  128. *
  129. * @param field The name of the field to compare.
  130. * @param value The value the field must be equal to.
  131. *
  132. * @return The created `Query`.
  133. */
  134. - (FIRQuery *)queryWhereField:(NSString *)field
  135. isNotEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isNotEqualTo:));
  136. /**
  137. * Creates and returns a new `Query` with the additional filter that documents must
  138. * contain the specified field and the value must be equal to the specified value.
  139. *
  140. * @param path The path of the field to compare.
  141. * @param value The value the field must be equal to.
  142. *
  143. * @return The created `Query`.
  144. */
  145. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  146. isEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isEqualTo:));
  147. /**
  148. * Creates and returns a new `Query` with the additional filter that documents must
  149. * contain the specified field and the value must be less than the specified value.
  150. *
  151. * @param field The name of the field to compare.
  152. * @param value The value the field must be less than.
  153. *
  154. * @return The created `Query`.
  155. */
  156. - (FIRQuery *)queryWhereField:(NSString *)field
  157. isLessThan:(id)value NS_SWIFT_NAME(whereField(_:isLessThan:));
  158. /**
  159. * Creates and returns a new `Query` with the additional filter that documents must
  160. * contain the specified field and the value must be less than the specified value.
  161. *
  162. * @param path The path of the field to compare.
  163. * @param value The value the field must be less than.
  164. *
  165. * @return The created `Query`.
  166. */
  167. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  168. isLessThan:(id)value NS_SWIFT_NAME(whereField(_:isLessThan:));
  169. /**
  170. * Creates and returns a new `Query` with the additional filter that documents must
  171. * contain the specified field and the value must be less than or equal to the specified value.
  172. *
  173. * @param field The name of the field to compare
  174. * @param value The value the field must be less than or equal to.
  175. *
  176. * @return The created `Query`.
  177. */
  178. - (FIRQuery *)queryWhereField:(NSString *)field
  179. isLessThanOrEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isLessThanOrEqualTo:));
  180. /**
  181. * Creates and returns a new `Query` with the additional filter that documents must
  182. * contain the specified field and the value must be less than or equal to the specified value.
  183. *
  184. * @param path The path of the field to compare
  185. * @param value The value the field must be less than or equal to.
  186. *
  187. * @return The created `Query`.
  188. */
  189. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  190. isLessThanOrEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isLessThanOrEqualTo:));
  191. /**
  192. * Creates and returns a new `Query` with the additional filter that documents must
  193. * contain the specified field and the value must greater than the specified value.
  194. *
  195. * @param field The name of the field to compare
  196. * @param value The value the field must be greater than.
  197. *
  198. * @return The created `Query`.
  199. */
  200. - (FIRQuery *)queryWhereField:(NSString *)field
  201. isGreaterThan:(id)value NS_SWIFT_NAME(whereField(_:isGreaterThan:));
  202. /**
  203. * Creates and returns a new `Query` with the additional filter that documents must
  204. * contain the specified field and the value must greater than the specified value.
  205. *
  206. * @param path The path of the field to compare
  207. * @param value The value the field must be greater than.
  208. *
  209. * @return The created `Query`.
  210. */
  211. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  212. isGreaterThan:(id)value NS_SWIFT_NAME(whereField(_:isGreaterThan:));
  213. /**
  214. * Creates and returns a new `Query` with the additional filter that documents must
  215. * contain the specified field and the value must be greater than or equal to the specified value.
  216. *
  217. * @param field The name of the field to compare
  218. * @param value The value the field must be greater than.
  219. *
  220. * @return The created `Query`.
  221. */
  222. - (FIRQuery *)queryWhereField:(NSString *)field
  223. isGreaterThanOrEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isGreaterThanOrEqualTo:));
  224. /**
  225. * Creates and returns a new `Query` with the additional filter that documents must
  226. * contain the specified field and the value must be greater than or equal to the specified value.
  227. *
  228. * @param path The path of the field to compare
  229. * @param value The value the field must be greater than.
  230. *
  231. * @return The created `Query`.
  232. */
  233. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  234. isGreaterThanOrEqualTo:(id)value NS_SWIFT_NAME(whereField(_:isGreaterThanOrEqualTo:));
  235. /**
  236. * Creates and returns a new `Query` with the additional filter that documents must contain
  237. * the specified field, it must be an array, and the array must contain the provided value.
  238. *
  239. * A query can have only one `arrayContains` filter.
  240. *
  241. * @param field The name of the field containing an array to search
  242. * @param value The value that must be contained in the array
  243. *
  244. * @return The created `Query`.
  245. */
  246. - (FIRQuery *)queryWhereField:(NSString *)field
  247. arrayContains:(id)value NS_SWIFT_NAME(whereField(_:arrayContains:));
  248. /**
  249. * Creates and returns a new `Query` with the additional filter that documents must contain
  250. * the specified field, it must be an array, and the array must contain the provided value.
  251. *
  252. * A query can have only one `arrayContains` filter.
  253. *
  254. * @param path The path of the field containing an array to search
  255. * @param value The value that must be contained in the array
  256. *
  257. * @return The created `Query`.
  258. */
  259. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  260. arrayContains:(id)value NS_SWIFT_NAME(whereField(_:arrayContains:));
  261. /**
  262. * Creates and returns a new `Query` with the additional filter that documents must contain
  263. * the specified field, the value must be an array, and that array must contain at least one value
  264. * from the provided array.
  265. *
  266. * A query can have only one `arrayContainsAny` filter and it cannot be combined with
  267. * `arrayContains` or `in` filters.
  268. *
  269. * @param field The name of the field containing an array to search.
  270. * @param values The array that contains the values to match.
  271. *
  272. * @return The created `Query`.
  273. */
  274. - (FIRQuery *)queryWhereField:(NSString *)field
  275. arrayContainsAny:(NSArray<id> *)values NS_SWIFT_NAME(whereField(_:arrayContainsAny:));
  276. /**
  277. * Creates and returns a new `Query` with the additional filter that documents must contain
  278. * the specified field, the value must be an array, and that array must contain at least one value
  279. * from the provided array.
  280. *
  281. * A query can have only one `arrayContainsAny` filter and it cannot be combined with
  282. * `arrayContains` or `in` filters.
  283. *
  284. * @param path The path of the field containing an array to search.
  285. * @param values The array that contains the values to match.
  286. *
  287. * @return The created `Query`.
  288. */
  289. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  290. arrayContainsAny:(NSArray<id> *)values
  291. NS_SWIFT_NAME(whereField(_:arrayContainsAny:));
  292. /**
  293. * Creates and returns a new `Query` with the additional filter that documents must contain
  294. * the specified field and the value must equal one of the values from the provided array.
  295. *
  296. * A query can have only one `in` filter, and it cannot be combined with an `arrayContainsAny`
  297. * filter.
  298. *
  299. * @param field The name of the field to search.
  300. * @param values The array that contains the values to match.
  301. *
  302. * @return The created `Query`.
  303. */
  304. - (FIRQuery *)queryWhereField:(NSString *)field
  305. in:(NSArray<id> *)values NS_SWIFT_NAME(whereField(_:in:));
  306. /**
  307. * Creates and returns a new `Query` with the additional filter that documents must contain
  308. * the specified field and the value must equal one of the values from the provided array.
  309. *
  310. * A query can have only one `in` filter, and it cannot be combined with an `arrayContainsAny`
  311. * filter.
  312. *
  313. * @param path The path of the field to search.
  314. * @param values The array that contains the values to match.
  315. *
  316. * @return The created `Query`.
  317. */
  318. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  319. in:(NSArray<id> *)values NS_SWIFT_NAME(whereField(_:in:));
  320. /**
  321. * Creates and returns a new `Query` with the additional filter that documents must contain
  322. * the specified field and the value does not equal any of the values from the provided array.
  323. *
  324. * One special case is that `notIn` filters cannot match `nil` values. To query for documents
  325. * where a field exists and is `nil`, use a `notEqual` filter, which can handle this special case.
  326. *
  327. * A query can have only one `notIn` filter, and it cannot be combined with an `arrayContains`,
  328. * `arrayContainsAny`, `in`, or `notEqual` filter.
  329. *
  330. * @param field The name of the field to search.
  331. * @param values The array that contains the values to match.
  332. *
  333. * @return The created `Query`.
  334. */
  335. - (FIRQuery *)queryWhereField:(NSString *)field
  336. notIn:(NSArray<id> *)values NS_SWIFT_NAME(whereField(_:notIn:));
  337. /**
  338. * Creates and returns a new `Query` with the additional filter that documents must contain
  339. * the specified field and the value does not equal any of the values from the provided array.
  340. *
  341. * One special case is that `notIn` filters cannot match `nil` values. To query for documents
  342. * where a field exists and is `nil`, use a `notEqual` filter, which can handle this special case.
  343. *
  344. * Passing in a `null` value into the `values` array results in no document matches. To query
  345. * for documents where a field is not `null`, use a `notEqual` filter.
  346. *
  347. * @param path The path of the field to search.
  348. * @param values The array that contains the values to match.
  349. *
  350. * @return The created `Query`.
  351. */
  352. - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path
  353. notIn:(NSArray<id> *)values NS_SWIFT_NAME(whereField(_:notIn:));
  354. /**
  355. * Creates and returns a new `Query` with the additional filter that documents must
  356. * satisfy the specified predicate.
  357. *
  358. * @param predicate The predicate the document must satisfy. Can be either comparison
  359. * or compound of comparison. In particular, block-based predicate is not supported.
  360. *
  361. * @return The created `Query`.
  362. */
  363. - (FIRQuery *)queryFilteredUsingPredicate:(NSPredicate *)predicate NS_SWIFT_NAME(filter(using:));
  364. #pragma mark - Sorting Data
  365. /**
  366. * Creates and returns a new `Query` that's additionally sorted by the specified field.
  367. *
  368. * @param field The field to sort by.
  369. *
  370. * @return The created `Query`.
  371. */
  372. - (FIRQuery *)queryOrderedByField:(NSString *)field NS_SWIFT_NAME(order(by:));
  373. /**
  374. * Creates and returns a new `Query` that's additionally sorted by the specified field.
  375. *
  376. * @param path The field to sort by.
  377. *
  378. * @return The created `Query`.
  379. */
  380. - (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)path NS_SWIFT_NAME(order(by:));
  381. /**
  382. * Creates and returns a new `Query` that's additionally sorted by the specified field,
  383. * optionally in descending order instead of ascending.
  384. *
  385. * @param field The field to sort by.
  386. * @param descending Whether to sort descending.
  387. *
  388. * @return The created `Query`.
  389. */
  390. - (FIRQuery *)queryOrderedByField:(NSString *)field
  391. descending:(BOOL)descending NS_SWIFT_NAME(order(by:descending:));
  392. /**
  393. * Creates and returns a new `Query` that's additionally sorted by the specified field,
  394. * optionally in descending order instead of ascending.
  395. *
  396. * @param path The field to sort by.
  397. * @param descending Whether to sort descending.
  398. *
  399. * @return The created `Query`.
  400. */
  401. - (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)path
  402. descending:(BOOL)descending NS_SWIFT_NAME(order(by:descending:));
  403. #pragma mark - Limiting Data
  404. /**
  405. * Creates and returns a new `Query` that only returns the first matching documents up to
  406. * the specified number.
  407. *
  408. * @param limit The maximum number of items to return.
  409. *
  410. * @return The created `Query`.
  411. */
  412. - (FIRQuery *)queryLimitedTo:(NSInteger)limit NS_SWIFT_NAME(limit(to:));
  413. /**
  414. * Creates and returns a new `Query` that only returns the last matching documents up to
  415. * the specified number.
  416. *
  417. * A query with a `limit(toLast:)` clause must have at least one `orderBy` clause.
  418. *
  419. * @param limit The maximum number of items to return.
  420. *
  421. * @return The created `Query`.
  422. */
  423. - (FIRQuery *)queryLimitedToLast:(NSInteger)limit NS_SWIFT_NAME(limit(toLast:));
  424. #pragma mark - Choosing Endpoints
  425. /**
  426. * Creates and returns a new `Query` that starts at the provided document (inclusive). The
  427. * starting position is relative to the order of the query. The document must contain all of the
  428. * fields provided in the orderBy of this query.
  429. *
  430. * @param document The snapshot of the document to start at.
  431. *
  432. * @return The created `Query`.
  433. */
  434. - (FIRQuery *)queryStartingAtDocument:(FIRDocumentSnapshot *)document
  435. NS_SWIFT_NAME(start(atDocument:));
  436. /**
  437. * Creates and returns a new `Query` that starts at the provided fields relative to the order of
  438. * the query. The order of the field values must match the order of the order by clauses of the
  439. * query.
  440. *
  441. * @param fieldValues The field values to start this query at, in order of the query's order by.
  442. *
  443. * @return The created `Query`.
  444. */
  445. - (FIRQuery *)queryStartingAtValues:(NSArray *)fieldValues NS_SWIFT_NAME(start(at:));
  446. /**
  447. * Creates and returns a new `Query` that starts after the provided document (exclusive). The
  448. * starting position is relative to the order of the query. The document must contain all of the
  449. * fields provided in the orderBy of this query.
  450. *
  451. * @param document The snapshot of the document to start after.
  452. *
  453. * @return The created `Query`.
  454. */
  455. - (FIRQuery *)queryStartingAfterDocument:(FIRDocumentSnapshot *)document
  456. NS_SWIFT_NAME(start(afterDocument:));
  457. /**
  458. * Creates and returns a new `Query` that starts after the provided fields relative to the order
  459. * of the query. The order of the field values must match the order of the order by clauses of the
  460. * query.
  461. *
  462. * @param fieldValues The field values to start this query after, in order of the query's orderBy.
  463. *
  464. * @return The created `Query`.
  465. */
  466. - (FIRQuery *)queryStartingAfterValues:(NSArray *)fieldValues NS_SWIFT_NAME(start(after:));
  467. /**
  468. * Creates and returns a new `Query` that ends before the provided document (exclusive). The end
  469. * position is relative to the order of the query. The document must contain all of the fields
  470. * provided in the orderBy of this query.
  471. *
  472. * @param document The snapshot of the document to end before.
  473. *
  474. * @return The created `Query`.
  475. */
  476. - (FIRQuery *)queryEndingBeforeDocument:(FIRDocumentSnapshot *)document
  477. NS_SWIFT_NAME(end(beforeDocument:));
  478. /**
  479. * Creates and returns a new `Query` that ends before the provided fields relative to the order
  480. * of the query. The order of the field values must match the order of the order by clauses of the
  481. * query.
  482. *
  483. * @param fieldValues The field values to end this query before, in order of the query's order by.
  484. *
  485. * @return The created `Query`.
  486. */
  487. - (FIRQuery *)queryEndingBeforeValues:(NSArray *)fieldValues NS_SWIFT_NAME(end(before:));
  488. /**
  489. * Creates and returns a new `Query` that ends at the provided document (exclusive). The end
  490. * position is relative to the order of the query. The document must contain all of the fields
  491. * provided in the orderBy of this query.
  492. *
  493. * @param document The snapshot of the document to end at.
  494. *
  495. * @return The created `Query`.
  496. */
  497. - (FIRQuery *)queryEndingAtDocument:(FIRDocumentSnapshot *)document NS_SWIFT_NAME(end(atDocument:));
  498. /**
  499. * Creates and returns a new `Query` that ends at the provided fields relative to the order of
  500. * the query. The order of the field values must match the order of the order by clauses of the
  501. * query.
  502. *
  503. * @param fieldValues The field values to end this query at, in order of the query's order by.
  504. *
  505. * @return The created `Query`.
  506. */
  507. - (FIRQuery *)queryEndingAtValues:(NSArray *)fieldValues NS_SWIFT_NAME(end(at:));
  508. #pragma mark - Aggregation
  509. /**
  510. * A query that counts the documents in the result set of this query without actually downloading
  511. * the documents.
  512. *
  513. * Using this `AggregateQuery` to count the documents is efficient because only the final count, not
  514. * the documents' data, is downloaded. The `AggregateQuery` can count the documents in cases where
  515. * the result set is prohibitively large to download entirely (thousands of documents).
  516. */
  517. @property(nonatomic, readonly) FIRAggregateQuery *count;
  518. /**
  519. * Creates and returns a new `AggregateQuery` that aggregates the documents in the result set
  520. * of this query without actually downloading the documents.
  521. *
  522. * Using an `AggregateQuery` to perform aggregations is efficient because only the final aggregation
  523. * values, not the documents' data, is downloaded. The returned `AggregateQuery` can perform
  524. * aggregations of the documents in cases where the result set is prohibitively large to download
  525. * entirely (thousands of documents).
  526. *
  527. * @param aggregateFields Specifies the aggregate operations to perform on the result set of this
  528. * query.
  529. *
  530. * @return An `AggregateQuery` encapsulating this `Query` and `AggregateField`s, which can be used
  531. * to query the server for the aggregation results.
  532. */
  533. - (FIRAggregateQuery *)aggregate:(NSArray<FIRAggregateField *> *)aggregateFields
  534. NS_SWIFT_NAME(aggregate(_:));
  535. @end
  536. NS_ASSUME_NONNULL_END