Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@firebase/firestore
Advanced tools
This is the [Cloud Firestore](https://firebase.google.com/docs/firestore/) component of the [Firebase JS SDK](https://www.npmjs.com/package/firebase).
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.
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());
});
});
Mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB. Compared to @firebase/firestore, Mongoose is specific to MongoDB and does not offer real-time data synchronization.
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication, and more. Unlike @firebase/firestore, Sequelize is focused on SQL databases and does not provide real-time data updates or offline support.
PouchDB is an open-source JavaScript database that allows you to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login. While it offers offline data storage and sync capabilities similar to Firestore, it is more suited for applications that require data to be stored locally on the user's device.
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.
You can then use the firebase namespace exposed by this package as illustrated below:
ES Modules
import firebase from '@firebase/app';
import '@firebase/firestore'
// Do stuff w/ `firebase` and `firebase.firestore`
CommonJS Modules
const firebase = require('@firebase/app').default;
require('@firebase/firestore');
// Do stuff with `firebase` and `firebase.firestore`
For comprehensive documentation please see the Firebase Reference Docs.
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
The Cloud Firestore component of the Firebase JS SDK.
The npm package @firebase/firestore receives a total of 378,235 weekly downloads. As such, @firebase/firestore popularity was classified as popular.
We found that @firebase/firestore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.