FIRQuery.h 23 KB

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