Skip to content

Commit a77c64f

Browse files
Add startAfter() and endBefore() to database types
1 parent 5380e00 commit a77c64f

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

packages/database-types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type EventType =
7171
| 'child_removed';
7272

7373
export interface Query {
74+
endBefore(value: number | string | boolean | null, key?: string): Query;
7475
endAt(value: number | string | boolean | null, key?: string): Query;
7576
equalTo(value: number | string | boolean | null, key?: string): Query;
7677
isEqual(other: Query | null): boolean;
@@ -100,6 +101,7 @@ export interface Query {
100101
orderByValue(): Query;
101102
ref: Reference;
102103
startAt(value: number | string | boolean | null, key?: string): Query;
104+
startAfter(value: number | string | boolean | null, key?: string): Query;
103105
toJSON(): Object;
104106
toString(): string;
105107
}

packages/firebase/index.d.ts

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5942,8 +5942,8 @@ declare namespace firebase.database {
59425942
/**
59435943
* Creates a `Query` with the specified ending point.
59445944
*
5945-
* Using `startAt()`, `endAt()`, and `equalTo()` allows you to choose arbitrary
5946-
* starting and ending points for your queries.
5945+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
5946+
* allows you to choose arbitrary starting and ending points for your queries.
59475947
*
59485948
* The ending point is inclusive, so children with exactly the specified value
59495949
* will be included in the query. The optional key argument can be used to
@@ -5977,11 +5977,34 @@ declare namespace firebase.database {
59775977
value: number | string | boolean | null,
59785978
key?: string
59795979
): firebase.database.Query;
5980+
/**
5981+
* Creates a `Query` with the specified ending point (exclusive).
5982+
*
5983+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
5984+
* allows you to choose arbitrary starting and ending points for your queries.
5985+
*
5986+
* The ending point is exclusive. If only a value is provided, children
5987+
* with a value less than the specified value will be included in the query.
5988+
* If a key is specified, then children must have a value lesss than or equal
5989+
* to the specified value and a a key name less than the specified key.
5990+
*
5991+
* @param value The value to end before. The argument
5992+
* type depends on which `orderBy*()` function was used in this query.
5993+
* Specify a value that matches the `orderBy*()` type. When used in
5994+
* combination with `orderByKey()`, the value must be a string.
5995+
* @param key The child key to end before, among the children with the
5996+
* previously specified priority. This argument is only allowed if ordering by
5997+
* child, value, or priority.
5998+
*/
5999+
endBefore(
6000+
value: number | string | boolean | null,
6001+
key?: string
6002+
): firebase.database.Query;
59806003
/**
59816004
* Creates a `Query` that includes children that match the specified value.
59826005
*
5983-
* Using `startAt()`, `endAt()`, and `equalTo()` allows us to choose arbitrary
5984-
* starting and ending points for our queries.
6006+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
6007+
* allows you to choose arbitrary starting and ending points for your queries.
59856008
*
59866009
* The optional key argument can be used to further limit the range of the
59876010
* query. If it is specified, then children that have exactly the specified
@@ -6426,8 +6449,8 @@ declare namespace firebase.database {
64266449
/**
64276450
* Creates a `Query` with the specified starting point.
64286451
*
6429-
* Using `startAt()`, `endAt()`, and `equalTo()` allows you to choose arbitrary
6430-
* starting and ending points for your queries.
6452+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
6453+
* allows you to choose arbitrary starting and ending points for your queries.
64316454
*
64326455
* The starting point is inclusive, so children with exactly the specified value
64336456
* will be included in the query. The optional key argument can be used to
@@ -6460,6 +6483,37 @@ declare namespace firebase.database {
64606483
value: number | string | boolean | null,
64616484
key?: string
64626485
): firebase.database.Query;
6486+
/**
6487+
* Creates a `Query` with the specified starting point (exclusive).
6488+
*
6489+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
6490+
* allows you to choose arbitrary starting and ending points for your queries.
6491+
*
6492+
* The starting point is exclusive. If only a value is provided, children
6493+
* with a value greater than the specified value will be included in the query.
6494+
* If a key is specified, then children must have a value greater than or equal
6495+
* to the specified value and a a key name greater than the specified key.
6496+
*
6497+
* @example
6498+
* ```javascript
6499+
* // Find all dinosaurs that are more than three meters tall.
6500+
* var ref = firebase.database().ref("dinosaurs");
6501+
* ref.orderByChild("height").startAfter(3).on("child_added", function(snapshot) {
6502+
* console.log(snapshot.key)
6503+
* });
6504+
* ```
6505+
*
6506+
* @param value The value to start after. The argument
6507+
* type depends on which `orderBy*()` function was used in this query.
6508+
* Specify a value that matches the `orderBy*()` type. When used in
6509+
* combination with `orderByKey()`, the value must be a string.
6510+
* @param key The child key to start after. This argument is only allowed
6511+
* if ordering by child, value, or priority.
6512+
*/
6513+
startAfter(
6514+
value: number | string | boolean | null,
6515+
key?: string
6516+
): firebase.database.Query;
64636517
/**
64646518
* Returns a JSON-serializable representation of this object.
64656519
*

0 commit comments

Comments
 (0)