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

@firebase/firestore

Package Overview
Dependencies
Maintainers
4
Versions
3572
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/firestore

The Cloud Firestore component of the Firebase JS SDK.

  • 4.7.4-canary.052e438bc
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
721K
decreased by-62.54%
Maintainers
4
Weekly downloads
 
Created

What is @firebase/firestore?

The @firebase/firestore package is a part of the Firebase JavaScript SDK, providing a powerful, scalable database for mobile, web, and server development. It offers real-time synchronization, offline support, and efficient data querying capabilities. This package allows developers to interact with Firestore, a NoSQL cloud database to store and sync data for client- and server-side development.

What are @firebase/firestore's main functionalities?

Adding Data

This feature allows you to add new documents to your Firestore database. The code sample demonstrates adding a new user with name and age fields to a 'users' collection.

db.collection('users').add({
  name: 'Ada Lovelace',
  age: 36
});

Reading Data

This feature enables reading documents from your Firestore database. The code sample shows how to fetch a document by its ID from the 'users' collection and log its data.

db.collection('users').doc('userId').get().then((doc) => {
  if (doc.exists) {
    console.log('Document data:', doc.data());
  } else {
    console.log('No such document!');
  }
});

Listening for Real-time Updates

This feature provides real-time updates on data changes. The code sample demonstrates setting up a listener on a user document to log updates in real-time.

db.collection('users').doc('userId')
  .onSnapshot((doc) => {
    console.log('Current data: ', doc.data());
  });

Querying Data

This feature allows querying documents based on certain conditions. The code sample shows how to query all users older than 18 years and log their data.

db.collection('users').where('age', '>', 18)
  .get()
  .then((querySnapshot) => {
    querySnapshot.forEach((doc) => {
      console.log(doc.id, ' => ', doc.data());
    });
  });

Other packages similar to @firebase/firestore

FAQs

Package last updated on 23 Oct 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