I am using Firestore in my project, so i want to show all collection names in my project.
Is it posible to get all collection names from Firebase project.
Thanks..
js admin clients have listCollections() on Firestore to get that list. Or, if you're looking for subcollections nested under a document, use DocumentReference. listCollections(). If you want to get a list on any platform, you should maintain that list yourself in a known collection inside a known document id.
You can read from a collection by querying it directly via the collection name. There are four different types of methods that you can use to keep track of any changes that may occur against your Firebase data. This will return a list of data. There is no document metadata and makes it simple to render to a view.
There are limited public APIs to get a list of top-level collections. Mobile clients (Android, iOS, web) have no API. Node.js admin clients have listCollections() on Firestore to get that list. Or, if you're looking for subcollections nested under a document, use DocumentReference.listCollections().
If you want to get a list on any platform, you should maintain that list yourself in a known collection inside a known document id.
You can do the following:
const admin = require("firebase-admin"); const db = admin.firestore(); db.listCollections() .then(snapshot=>{ snapshot.forEach(snaps => { console.log(snaps["_queryOptions"].collectionId); // LIST OF ALL COLLECTIONS }) }) .catch(error => console.error(error));
This works with NodeJS.
Remember that you will need to download firebase-admin
and do the necessary configuration for Firebase server side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With