Socket
Socket
Sign inDemoInstall

firebase-childrenkeys

Package Overview
Dependencies
2
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-childrenkeys

Fetch children keys of Firebase Admin Database References via the REST API


Version published
Maintainers
2
Weekly downloads
92
decreased by-55.56%

Weekly downloads

Readme

Source

firebase-childrenkeys

Exports a method which fetches the children keys of a Firebase Admin Database Reference via the REST API.

API Reference

The default export is a method with the following signature:

(ref[, options]) => string[]

Arguments

ref is a Firebase Admin Database Reference.

options is an optional object containing the following configuration options:

  • maxRetries - The maximum number of times to try to fetch the keys, in case of transient errors (defaults to 1).
  • retryInterval - The number of milliseconds to delay between retries (defaults to 1000).
  • agent - The HTTP(S) agent to use when requesting data (defaults to none).

Return Value

An array of strings representing the children keys of the provided Firebase Admin Database Reference. If the provided reference has no children, the return value will be an empty array.

Example Usage

const admin = require('firebase-admin');
const firebaseChildrenKeys = require('firebase-childrenkeys');

admin.initializeApp(
  // ...
);

const db = admin.database();
const fooRef = db.ref('foo');

// Fetch all children keys of fooRef.
firebaseChildrenKeys(fooRef)
  .then((keys) => {
    if (keys.length === 0) {
      console.log('No children keys found.');
    }

    keys.forEach((key) => {
      console.log('Found child key:', key);
    });
  })
  .catch((error) => {
    console.log('Failed to fetch children keys:', error);
  });

// Fetch all children keys of fooRef, with an optional configuration.
firebaseChildrenKeys(fooRef, {
  maxRetries: 5,
  retryInterval: 500,
})
  .then((keys) => {
    if (keys.length === 0) {
      console.log('No children keys found.');
    }

    keys.forEach((key) => {
      console.log('Found child key:', key);
    });
  })
  .catch((error) => {
    console.log('Failed to fetch children keys:', error);
  });

Keywords

FAQs

Last updated on 08 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc