Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@firebase/firestore
Advanced tools
This is the Firestore component for the Firebase JS SDK. It has a peer dependency on the [`@firebase/app`](https://npm.im/@firebase/app) package on NPM. This package **is not** included by default in the [`firebase`](https://npm.im/firebase) wrapper packa
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 Firestore component for the Firebase JS SDK. It has a peer
dependency on the @firebase/app
package on NPM. This package
is not included by default in the firebase
wrapper package.
You can install this package by running the following in your project:
$ npm install @firebase/firestore
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.
FAQs
The Cloud Firestore component of the Firebase JS SDK.
The npm package @firebase/firestore receives a total of 1,586,904 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.