I have a large collection of large documents stored in Firestore. As fetching the entire collection would be costly, I would like to fetch a list of document ids for my user and only fetch the document data after my user makes his selection.
This is how I'm fetching the documents ids
const querySnapshot = await db
.collection("myCollection")
.get()
const ids = querySnapshot.docs.map((document) => document.id);
Unfortunately, I believe that the above code fetches both the document id as well as the document data. Is there any way to fetch only the document id without fetching the document data?
If the above is not possible due to Firestore's limitations, what is the best practice for maintaining a second collection to keep track of document ids in the first collection? Does Firebase support any kind of "on insert/on delete" hook using cloud functions that can automatically maintain this second collection for me?