Skip to content

Commit 03254aa

Browse files
committed
Corrected and improved comments.
1 parent a0e5d30 commit 03254aa

File tree

1 file changed

+79
-67
lines changed

1 file changed

+79
-67
lines changed

packages/firestore/src/lite-api/query.ts

Lines changed: 79 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,20 @@ export function query<T>(
127127
}
128128

129129
/**
130-
* A `QueryFilterConstraint` is used to narrow the set of documents returned by a
131-
* Firestore query by filtering on one or more document fields. `QueryFilterConstraint`s are created by invoking {@link where},
132-
* {@link or} or {@link and} and
133-
* can then be passed to {@link query} to create a new query instance that
134-
* also contains this `QueryFilterConstraint`.
130+
* A `QueryFilterConstraint` is used to narrow the set of documents returned by
131+
* a Firestore query by filtering on one or more document fields.
132+
* `QueryFilterConstraint`s are created by invoking {@link where}, {@link or} or
133+
* {@link and} and can then be passed to {@link query} to create a new query
134+
* instance that also contains this `QueryFilterConstraint`.
135135
*/
136136
export abstract class QueryFilterConstraint extends QueryConstraint {
137137
abstract _parse<T>(query: Query<T>): Filter;
138138
}
139139

140140
/**
141-
* A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by a
142-
* Firestore query by filtering on one document field. `QueryFieldFilterConstraint`s are created by invoking {@link where} and
141+
* A `QueryFieldFilterConstraint` is used to narrow the set of documents
142+
* returned by a Firestore query by filtering on one document field.
143+
* `QueryFieldFilterConstraint`s are created by invoking {@link where} and
143144
* can then be passed to {@link query} to create a new query instance that
144145
* also contains this `QueryFieldFilterConstraint`.
145146
*/
@@ -205,9 +206,9 @@ export type WhereFilterOp =
205206
| 'not-in';
206207

207208
/**
208-
* Creates a {@link QueryFieldFilterConstraint} that enforces that documents must contain the
209-
* specified field and that the value should satisfy the relation constraint
210-
* provided.
209+
* Creates a {@link QueryFieldFilterConstraint} that enforces that documents
210+
* must contain the specified field and that the value should satisfy the
211+
* relation constraint provided.
211212
*
212213
* @param fieldPath - The path to compare
213214
* @param opStr - The operation string (e.g "&lt;", "&lt;=", "==", "&lt;",
@@ -226,11 +227,12 @@ export function where(
226227
}
227228

228229
/**
229-
* A `QueryCompositeFilterConstraint` is used to narrow the set of documents returned by a
230-
* Firestore query by performing the logical OR or AND of multiple {@link QueryFieldFilterConstraint} or {@link QueryCompositeFilterConstraint}.
231-
* `QueryCompositeFilterConstraint`s are created by invoking {@link or} or {@link and} and
232-
* can then be passed to {@link query} to create a new query instance that
233-
* also contains this `QueryCompositeFilterConstraint`.
230+
* A `QueryCompositeFilterConstraint` is used to narrow the set of documents
231+
* returned by a Firestore query by performing the logical OR or AND of multiple
232+
* {@link QueryFieldFilterConstraint} or {@link QueryCompositeFilterConstraint}.
233+
* `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
234+
* {@link and} and can then be passed to {@link query} to create a new query
235+
* instance that also contains this `QueryCompositeFilterConstraint`.
234236
*/
235237
export class QueryCompositeFilterConstraint extends QueryFilterConstraint {
236238
protected constructor(
@@ -264,7 +266,8 @@ export class QueryCompositeFilterConstraint extends QueryFilterConstraint {
264266
_apply<T>(query: Query<T>): Query<T> {
265267
const parsedFilter = this._parse(query);
266268
if (parsedFilter.getFilters().length === 0) {
267-
// Return the existing query if not adding any more filters (e.g. an empty composite filter).
269+
// Return the existing query if not adding any more filters (e.g. an empty
270+
// composite filter).
268271
return query;
269272
}
270273
validateNewFilter(query._query, parsedFilter);
@@ -289,8 +292,9 @@ export class QueryCompositeFilterConstraint extends QueryFilterConstraint {
289292
* Creates a {@link QueryCompositeFilterConstraint} that performs a logical OR
290293
* of all the provided {@link QueryFilterConstraint}.
291294
*
292-
* @param queryConstraints - Optional. The {@link queryConstraints} for OR operation. These must be
293-
* created with calls to {@link where}, {@link or}, or {@link and}.
295+
* @param queryConstraints - Optional. The {@link queryConstraints} for OR
296+
* operation. These must be created with calls to {@link where}, {@link or}, or
297+
* {@link and}.
294298
* @returns The created {@link QueryCompositeFilterConstraint}.
295299
*/
296300
export function or(
@@ -311,8 +315,9 @@ export function or(
311315
* Creates a {@link QueryCompositeFilterConstraint} that performs a logical AND
312316
* of all the provided {@link QueryFilterConstraint}.
313317
*
314-
* @param queryConstraints - Optional. The {@link queryConstraints} for AND operation. These must be
315-
* created with calls to {@link where}, {@link or}, or {@link and}.
318+
* @param queryConstraints - Optional. The {@link queryConstraints} for AND
319+
* operation. These must be created with calls to {@link where}, {@link or}, or
320+
* {@link and}.
316321
* @returns The created {@link QueryCompositeFilterConstraint}.
317322
*/
318323
export function and(
@@ -331,10 +336,12 @@ export function and(
331336

332337
/**
333338
* A `QueryOrderByConstraint` is used to sort the set of documents returned by a
334-
* Firestore query.
335-
* `QueryOrderByConstraint`s are created by invoking {@link orderBy} and
336-
* can then be passed to {@link query} to create a new query instance that
337-
* also contains this `QueryOrderByConstraint`.
339+
* Firestore query. `QueryOrderByConstraint`s are created by invoking
340+
* {@link orderBy} and can then be passed to {@link query} to create a new query
341+
* instance that also contains this `QueryOrderByConstraint`.
342+
*
343+
* Note: Documents that do not contain the orderBy field will not be present in
344+
* the query result.
338345
*/
339346
export class QueryOrderByConstraint extends QueryConstraint {
340347
readonly type = 'orderBy';
@@ -373,6 +380,9 @@ export type OrderByDirection = 'desc' | 'asc';
373380
* Creates a {@link QueryOrderByConstraint} that sorts the query result by the
374381
* specified field, optionally in descending order instead of ascending.
375382
*
383+
* Note: Documents that do not contain the specified field will not be present
384+
* in the query result.
385+
*
376386
* @param fieldPath - The field to sort by.
377387
* @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
378388
* not specified, order will be ascending.
@@ -388,11 +398,11 @@ export function orderBy(
388398
}
389399

390400
/**
391-
* A `QueryLimitConstraint` is used to limit the number of documents returned by a
392-
* Firestore query.
393-
* `QueryLimitConstraint`s are created by invoking {@link limit} or {@link limitToLast} and
394-
* can then be passed to {@link query} to create a new query instance that
395-
* also contains this `QueryLimitConstraint`.
401+
* A `QueryLimitConstraint` is used to limit the number of documents returned by
402+
* a Firestore query.
403+
* `QueryLimitConstraint`s are created by invoking {@link limit} or
404+
* {@link limitToLast} and can then be passed to {@link query} to create a new
405+
* query instance that also contains this `QueryLimitConstraint`.
396406
*/
397407
export class QueryLimitConstraint extends QueryConstraint {
398408
protected constructor(
@@ -421,7 +431,8 @@ export class QueryLimitConstraint extends QueryConstraint {
421431
}
422432

423433
/**
424-
* Creates a {@link QueryLimitConstraint} that only returns the first matching documents.
434+
* Creates a {@link QueryLimitConstraint} that only returns the first matching
435+
* documents.
425436
*
426437
* @param limit - The maximum number of items to return.
427438
* @returns The created {@link QueryLimitConstraint}.
@@ -432,7 +443,8 @@ export function limit(limit: number): QueryLimitConstraint {
432443
}
433444

434445
/**
435-
* Creates a {@link QueryLimitConstraint} that only returns the last matching documents.
446+
* Creates a {@link QueryLimitConstraint} that only returns the last matching
447+
* documents.
436448
*
437449
* You must specify at least one `orderBy` clause for `limitToLast` queries,
438450
* otherwise an exception will be thrown during execution.
@@ -446,11 +458,11 @@ export function limitToLast(limit: number): QueryLimitConstraint {
446458
}
447459

448460
/**
449-
* A `QueryStartAtConstraint` is used to exclude documents from the start of a result set returned by a
450-
* Firestore query.
451-
* `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or {@link (startAfter:1)} and
452-
* can then be passed to {@link query} to create a new query instance that
453-
* also contains this `QueryStartAtConstraint`.
461+
* A `QueryStartAtConstraint` is used to exclude documents from the start of a
462+
* result set returned by a Firestore query.
463+
* `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
464+
* {@link (startAfter:1)} and can then be passed to {@link query} to create a
465+
* new query instance that also contains this `QueryStartAtConstraint`.
454466
*/
455467
export class QueryStartAtConstraint extends QueryConstraint {
456468
protected constructor(
@@ -485,10 +497,10 @@ export class QueryStartAtConstraint extends QueryConstraint {
485497
}
486498

487499
/**
488-
* Creates a {@link QueryStartAtConstraint} that modifies the result set to start at the
489-
* provided document (inclusive). The starting position is relative to the order
490-
* of the query. The document must contain all of the fields provided in the
491-
* `orderBy` of this query.
500+
* Creates a {@link QueryStartAtConstraint} that modifies the result set to
501+
* start at the provided document (inclusive). The starting position is relative
502+
* to the order of the query. The document must contain all of the fields
503+
* provided in the `orderBy` of this query.
492504
*
493505
* @param snapshot - The snapshot of the document to start at.
494506
* @returns A {@link QueryStartAtConstraint} to pass to `query()`.
@@ -497,9 +509,9 @@ export function startAt(
497509
snapshot: DocumentSnapshot<unknown>
498510
): QueryStartAtConstraint;
499511
/**
500-
* Creates a {@link QueryStartAtConstraint} that modifies the result set to start at the
501-
* provided fields relative to the order of the query. The order of the field
502-
* values must match the order of the order by clauses of the query.
512+
* Creates a {@link QueryStartAtConstraint} that modifies the result set to
513+
* start at the provided fields relative to the order of the query. The order of
514+
* the field values must match the order of the order by clauses of the query.
503515
*
504516
* @param fieldValues - The field values to start this query at, in order
505517
* of the query's order by.
@@ -517,10 +529,10 @@ export function startAt(
517529
}
518530

519531
/**
520-
* Creates a {@link QueryStartAtConstraint} that modifies the result set to start after the
521-
* provided document (exclusive). The starting position is relative to the order
522-
* of the query. The document must contain all of the fields provided in the
523-
* orderBy of the query.
532+
* Creates a {@link QueryStartAtConstraint} that modifies the result set to
533+
* start after the provided document (exclusive). The starting position is
534+
* relative to the order of the query. The document must contain all of the
535+
* fields provided in the orderBy of the query.
524536
*
525537
* @param snapshot - The snapshot of the document to start after.
526538
* @returns A {@link QueryStartAtConstraint} to pass to `query()`
@@ -529,9 +541,9 @@ export function startAfter(
529541
snapshot: DocumentSnapshot<unknown>
530542
): QueryStartAtConstraint;
531543
/**
532-
* Creates a {@link QueryStartAtConstraint} that modifies the result set to start after the
533-
* provided fields relative to the order of the query. The order of the field
534-
* values must match the order of the order by clauses of the query.
544+
* Creates a {@link QueryStartAtConstraint} that modifies the result set to
545+
* start after the provided fields relative to the order of the query. The order
546+
* of the field values must match the order of the order by clauses of the query.
535547
*
536548
* @param fieldValues - The field values to start this query after, in order
537549
* of the query's order by.
@@ -549,11 +561,11 @@ export function startAfter(
549561
}
550562

551563
/**
552-
* A `QueryEndAtConstraint` is used to exclude documents from the end of a result set returned by a
553-
* Firestore query.
554-
* `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or {@link (endBefore:1)} and
555-
* can then be passed to {@link query} to create a new query instance that
556-
* also contains this `QueryEndAtConstraint`.
564+
* A `QueryEndAtConstraint` is used to exclude documents from the end of a
565+
* result set returned by a Firestore query.
566+
* `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
567+
* {@link (endBefore:1)} and can then be passed to {@link query} to create a new
568+
* query instance that also contains this `QueryEndAtConstraint`.
557569
*/
558570
export class QueryEndAtConstraint extends QueryConstraint {
559571
protected constructor(
@@ -588,10 +600,10 @@ export class QueryEndAtConstraint extends QueryConstraint {
588600
}
589601

590602
/**
591-
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end before the
592-
* provided document (exclusive). The end position is relative to the order of
593-
* the query. The document must contain all of the fields provided in the
594-
* orderBy of the query.
603+
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end
604+
* before the provided document (exclusive). The end position is relative to the
605+
* order of the query. The document must contain all of the fields provided in
606+
* the orderBy of the query.
595607
*
596608
* @param snapshot - The snapshot of the document to end before.
597609
* @returns A {@link QueryEndAtConstraint} to pass to `query()`
@@ -600,9 +612,9 @@ export function endBefore(
600612
snapshot: DocumentSnapshot<unknown>
601613
): QueryEndAtConstraint;
602614
/**
603-
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end before the
604-
* provided fields relative to the order of the query. The order of the field
605-
* values must match the order of the order by clauses of the query.
615+
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end
616+
* before the provided fields relative to the order of the query. The order of
617+
* the field values must match the order of the order by clauses of the query.
606618
*
607619
* @param fieldValues - The field values to end this query before, in order
608620
* of the query's order by.
@@ -620,9 +632,9 @@ export function endBefore(
620632
}
621633

622634
/**
623-
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end at the
624-
* provided document (inclusive). The end position is relative to the order of
625-
* the query. The document must contain all of the fields provided in the
635+
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
636+
* the provided document (inclusive). The end position is relative to the order
637+
* of the query. The document must contain all of the fields provided in the
626638
* orderBy of the query.
627639
*
628640
* @param snapshot - The snapshot of the document to end at.
@@ -632,8 +644,8 @@ export function endAt(
632644
snapshot: DocumentSnapshot<unknown>
633645
): QueryEndAtConstraint;
634646
/**
635-
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end at the
636-
* provided fields relative to the order of the query. The order of the field
647+
* Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
648+
* the provided fields relative to the order of the query. The order of the field
637649
* values must match the order of the order by clauses of the query.
638650
*
639651
* @param fieldValues - The field values to end this query at, in order

0 commit comments

Comments
 (0)