@@ -26,23 +26,16 @@ export namespace database {
2626 this . queryObject = firebase . webQuery ( this . path ) ;
2727 }
2828
29- /**
30- * Listens for data changes at a particular location
31- * @param eventType One of the following strings: "value", "child_added", "child_changed", "child_removed", or "child_moved."
32- * @param callback A callback that fires when the specified event occurs. The callback will be passed a DataSnapshot.
33- * @returns The provided callback function is returned unmodified.
34- */
29+ /**
30+ * Listens for data changes at a particular location
31+ * @param eventType One of the following strings: "value", "child_added", "child_changed", "child_removed", or "child_moved."
32+ * @param callback A callback that fires when the specified event occurs. The callback will be passed a DataSnapshot.
33+ * @returns The provided callback function is returned unmodified.
34+ */
3535 public on ( eventType : string , callback : ( a : DataSnapshot | null , b ?: string ) => any ,
3636 cancelCallbackOrContext ?: Object | null , context ?: Object | null ) : ( a : DataSnapshot | null , b ?: string ) => Function {
3737
38- /**
39- * Follow webApi which uses the eventType. Works right now but running into issue because we don't
40- * pass back a DataSnapshot with forEach / getChildren() implemented. So when an event fires the user
41- * gets the updated values, but it's not sorted. In Android and Web you would loop through the children
42- * (getChildren() and forEach()) which would be returned in the query order.
43- * See: https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot#forEach
44- */
45- this . queryObject . on ( eventType , callback ) . catch ( error => {
38+ this . queryObject . on ( eventType , callback ) . catch ( error => {
4639 console . log ( "firebase.database().on error: " + error ) ;
4740 } ) ;
4841 return callback ; // According to firebase doc we just return the callback given
@@ -63,7 +56,7 @@ export namespace database {
6356 */
6457 public once ( eventType : string , successCallback ?: ( a : DataSnapshot , b ?: string ) => any ,
6558 failureCallbackOrContext ?: Object | null , context ?: Object | null ) : Promise < DataSnapshot > {
66- return this . queryObject . once ( eventType ) ;
59+ return this . queryObject . once ( eventType ) ;
6760 }
6861
6962 /**
@@ -97,7 +90,42 @@ export namespace database {
9790 return this . queryObject . orderByValue ( ) ;
9891 }
9992
100- // Didn't expose the filterby functions because they should be run after an orderby. (TODO: Limitby are exceptions....)
93+ /**
94+ * Creates a Query with the specified starting point. The value to start at should match the type
95+ * passed to orderBy(). If using orderByKey(), the value must be a string
96+ */
97+ public startAt ( value : number | string | boolean | null ) : firebase . Query {
98+ return this . queryObject . startAt ( value ) ;
99+ }
100+
101+ /**
102+ * Creates a Query with the specified ending point. The value to start at should match the type
103+ * passed to orderBy(). If using orderByKey(), the value must be a string.
104+ */
105+ public endAt ( value : any , key ?: string ) : firebase . Query {
106+ return this . queryObject . endAt ( value , key ) ;
107+ }
108+
109+ /**
110+ * Generate a new Query limited to the first specific number of children.
111+ */
112+ public limitToFirst ( value : number ) : firebase . Query {
113+ return this . queryObject . limitToFirst ( value ) ;
114+ }
115+
116+ /**
117+ * Generate a new Query limited to the last specific number of children.
118+ */
119+ public limitToLast ( value : number ) : firebase . Query {
120+ return this . queryObject . limitToLast ( value ) ;
121+ }
122+
123+ /**
124+ * Creates a Query that includes children that match the specified value.
125+ */
126+ public equalTo ( value : any , key ?: string ) : firebase . Query {
127+ return this . queryObject . equalTo ( value , key ) ;
128+ }
101129 }
102130
103131 export class Reference extends Query {
0 commit comments