FIRQuery.h 23 KB

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