MCPcopy Create free account
hub / github.com/firebase/firebase-tools / RTDBListRemote

Class RTDBListRemote

src/database/listRemote.ts:23–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23export class RTDBListRemote implements ListRemote {
24 private apiClient: Client;
25
26 constructor(
27 private instance: string,
28 private host: string,
29 ) {
30 const url = new URL(utils.getDatabaseUrl(this.host, this.instance, "/"));
31 this.apiClient = new Client({ urlPrefix: url.origin, auth: true });
32 }
33
34 async listPath(
35 path: string,
36 numSubPath: number,
37 startAfter?: string,
38 timeout?: number,
39 ): Promise<string[]> {
40 const url = new URL(utils.getDatabaseUrl(this.host, this.instance, path + ".json"));
41
42 const params: any = {
43 shallow: true,
44 limitToFirst: numSubPath,
45 };
46 if (startAfter) {
47 params.startAfter = startAfter;
48 }
49 if (timeout) {
50 params.timeout = `${timeout}ms`;
51 }
52
53 const t0 = Date.now();
54 const res = await this.apiClient.get<{ [key: string]: unknown }>(url.pathname, {
55 queryParams: params,
56 });
57 const paths = res.body ? Object.keys(res.body) : [];
58 const dt = Date.now() - t0;
59 logger.debug(`[database] sucessfully fetched ${paths.length} path at ${path} ${dt}`);
60 return paths;
61 }
62}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…