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

@firebase/firestore-compat

Package Overview
Dependencies
Maintainers
4
Versions
1190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/firestore-compat

The Cloud Firestore component of the Firebase JS SDK.

  • 0.3.40
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
increased by6.57%
Maintainers
4
Weekly downloads
 
Created

What is @firebase/firestore-compat?

The @firebase/firestore-compat package is designed to provide compatibility with older versions of Firebase Firestore for projects that use the Firebase JavaScript SDK. It allows developers to use the new Firestore SDK in a way that is compatible with the older syntax and methods, facilitating easier upgrades and maintenance of legacy code.

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

Data Retrieval

This feature allows you to retrieve data from a Firestore database. The code sample demonstrates how to fetch a document from the 'users' collection using a specific user ID.

const db = firebase.firestore();
const docRef = db.collection('users').doc('user_id');
docRef.get().then((doc) => {
  if (doc.exists) {
    console.log('Document data:', doc.data());
  } else {
    console.log('No such document!');
  }
}).catch((error) => {
  console.log('Error getting document:', error);
});

Data Modification

This feature covers adding or updating data in Firestore. The code sample shows how to set data for a document in the 'users' collection, effectively creating or updating a document.

const db = firebase.firestore();
db.collection('users').doc('user_id').set({
  firstName: 'John',
  lastName: 'Doe'
}).then(() => {
  console.log('Document successfully written!');
}).catch((error) => {
  console.error('Error writing document: ', error);
});

Real-time Updates

This feature enables listening to real-time updates of a document in Firestore. The code sample illustrates how to subscribe to changes in a document, receiving updates automatically whenever the document data changes.

const db = firebase.firestore();
const docRef = db.collection('users').doc('user_id');
docRef.onSnapshot((doc) => {
  if (doc.exists) {
    console.log('Current data: ', doc.data());
  } else {
    console.log('No such document!');
  }
});

Other packages similar to @firebase/firestore-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