Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/database-compat

Package Overview
Dependencies
Maintainers
4
Versions
1084
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/database-compat

The Realtime Database component of the Firebase JS SDK.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
decreased by-16.03%
Maintainers
4
Weekly downloads
 
Created

What is @firebase/database-compat?

The @firebase/database-compat package is a compatibility layer for the Firebase Realtime Database, allowing developers to use the Firebase Realtime Database with legacy code that was written for older versions of Firebase. It provides an easy way to interact with Firebase Realtime Database using JavaScript, enabling real-time data synchronization and offline capabilities.

What are @firebase/database-compat's main functionalities?

Real-time Data Synchronization

This feature allows you to synchronize data in real-time. Any changes in the database are automatically and instantly reflected to all connected clients.

const { initializeApp } = require('firebase/app');
const { getDatabase, ref, onValue } = require('@firebase/database-compat');

const app = initializeApp({ /* your config */ });
const db = getDatabase(app);
const dbRef = ref(db, 'path/to/data');
onValue(dbRef, (snapshot) => {
  console.log(snapshot.val());
});

Data Retrieval

This feature allows you to retrieve data once without setting up a continuous listener. It's useful for fetching data at a specific moment.

const { getDatabase, ref, get } = require('@firebase/database-compat');

const db = getDatabase();
const dbRef = ref(db, 'path/to/data');
get(dbRef).then((snapshot) => {
  if (snapshot.exists()) {
    console.log(snapshot.val());
  } else {
    console.log('No data available');
  }
}).catch((error) => {
  console.error(error);
});

Write and Update Data

This feature allows you to write new data or update existing data at a specified path in the database.

const { getDatabase, ref, set, update } = require('@firebase/database-compat');

const db = getDatabase();
const dbRef = ref(db, 'path/to/data');
set(dbRef, { key: 'value' });
update(dbRef, { updatedKey: 'updatedValue' });

Other packages similar to @firebase/database-compat

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc