Firestore - Get document collections

Its possible on web (client side js)

db.collection('FirstCollection/' + id + '/DocSubCollectionName').get().then((subCollectionSnapshot) => {
    subCollectionSnapshot.forEach((subDoc) => {
        console.log(subDoc.data());
    });
});

Thanks to @marcogramy comment


firebase.initializeApp(config);

const db = firebase.firestore();

db.settings({timestampsInSnapshots: true});

const collection = db.collection('user_dat');

collection.get().then(snapshot => {

  snapshot.forEach(doc => {

    console.log( doc.data().name );    
    console.log( doc.data().mail );

  });

});

If you are using the Node.js server SDK you can use the getCollections() method on DocumentReference: https://cloud.google.com/nodejs/docs/reference/firestore/0.8.x/DocumentReference#getCollections

This method will return a promise for an array of CollectionReference objects which you can use to access the documents within the collections.


Update
API has been updated, now function is .listCollections() https://googleapis.dev/nodejs/firestore/latest/DocumentReference.html#listCollections


getCollections() method is available for NodeJS.

Sample code:

    db.collection("Collection").doc("Document").getCollections().then((querySnapshot) => {
    querySnapshot.forEach((collection) => {
        console.log("collection: " + collection.id);
        });
    });