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..
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.