Firebase 9 Firestore GET ALL DOCUMENTS Data From A Collection

Raja Tamil
3 min readJul 25, 2022

Learn how to get all the document data from a collection in Firebase version 9 Cloud Firestore Database using the getDocs() method.

The Firestore Database has a cities collection that has four documents in it like the screenshot below.

Import Firestore Database and de-structure three methods that are:

  • getFirestore() → Firestore Database
  • doc() → It takes references of the database and collection that we need to get the data from.
  • getDocs() → It gets data from collection based references mentioned in the doc() method.

import { getFirestore, doc, getDocs } from https://www.gstatic.com/firebasejs/9.8.4/firebase-firestore.js";

The import statement uses the CDN version of the Firebase SDK in this example.

Initialize Firestore Database

const db = getFirestore();

--

--

Raja Tamil
Raja Tamil

Written by Raja Tamil

👇click the link and get 80% OFF on the premium web development courses (HTML5, CSS3, JavaScript ES6, Vue JS 3 & Firebase 10 https://softauthor.com

No responses yet