Socket
Socket
Sign inDemoInstall

@firebase/firestore-compat

Package Overview
Dependencies
46
Maintainers
4
Versions
1076
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @firebase/firestore-compat

The Cloud Firestore component of the Firebase JS SDK.


Version published
Weekly downloads
1.4M
increased by3.29%
Maintainers
4
Created
Weekly downloads
 

Package description

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

Readme

Source

@firebase/firestore-compat

This is the Cloud Firestore component of the Firebase JS SDK.

This package is not intended for direct usage, and should only be used via the officially supported firebase package.

If you are developing a Node.js application that requires administrative access to Cloud Firestore, use the @google-cloud/firestore Server SDK with your developer credentials.

Documentation

For comprehensive documentation please see the Firebase Reference Docs.

Contributing

See Contributing to the Firebase SDK for general information about contributing to the firebase-js-sdk repo and Contributing to the Cloud Firestore Component for details specific to the Cloud Firestore code and tests.

FAQs

Last updated on 20 May 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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc