Socket
Socket
Sign inDemoInstall

@firebase/firestore

Package Overview
Dependencies
42
Maintainers
4
Versions
3403
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @firebase/firestore

The Cloud Firestore component of the Firebase JS SDK.


Version published
Weekly downloads
1.7M
increased by4.12%
Maintainers
4
Created
Weekly downloads
 

Package description

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

Readme

Source

@firebase/firestore

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 11 Apr 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