| 186 | } |
| 187 | |
| 188 | export class Query implements IQuery { |
| 189 | _native: FIRDatabaseQuery; |
| 190 | |
| 191 | static fromNative(query: FIRDatabaseQuery) { |
| 192 | if (query instanceof FIRDatabaseQuery) { |
| 193 | const q = new Query(); |
| 194 | q._native = query; |
| 195 | return q; |
| 196 | } |
| 197 | return null; |
| 198 | } |
| 199 | |
| 200 | get native() { |
| 201 | return this._native; |
| 202 | } |
| 203 | |
| 204 | get ios() { |
| 205 | return this.native; |
| 206 | } |
| 207 | |
| 208 | get ref(): Reference { |
| 209 | return Reference.fromNative(this.native.ref); |
| 210 | } |
| 211 | |
| 212 | endAt(value: string | number | boolean, key?: string): Query { |
| 213 | if (key) { |
| 214 | return Query.fromNative(this.native.queryEndingAtValueChildKey(value, key)); |
| 215 | } else { |
| 216 | return Query.fromNative(this.native.queryEndingAtValue(value)); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | equalTo(value: string | number | boolean, key?: string): Query { |
| 221 | if (key) { |
| 222 | return Query.fromNative(this.native.queryEqualToValueChildKey(value, key)); |
| 223 | } else { |
| 224 | return Query.fromNative(this.native.queryEqualToValue(value)); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | keepSynced(bool: boolean) { |
| 229 | this.native?.keepSynced?.(bool); |
| 230 | } |
| 231 | |
| 232 | limitToFirst(limit: number): Query { |
| 233 | return Query.fromNative(this.native.queryLimitedToFirst(limit)); |
| 234 | } |
| 235 | |
| 236 | limitToLast(limit: number): Query { |
| 237 | return Query.fromNative(this.native.queryLimitedToLast(limit)); |
| 238 | } |
| 239 | |
| 240 | _handles: Map<(a: DataSnapshot, b: string) => void, number> = new Map(); |
| 241 | |
| 242 | off(eventType?: EventType, callback?: (a: DataSnapshot, b: string) => void, context?: Record<string, any>): void { |
| 243 | const handle = callback?.['__fbHandle']; |
| 244 | const event = callback?.['__fbEventType']; |
| 245 | if (typeof handle === 'number' && event === eventType) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…