Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const getDocWithSubcollections = async (doc: any) => {
- const item: any = { id: doc.id, ...doc.data() };
- const subcollections = await doc.ref.listCollections();
- for (const sub of subcollections) {
- const arr = [];
- const subDocs = (await sub.get()).docs;
- for (const d of subDocs) {
- arr.push(await getDocWithSubcollections(d));
- }
- item[sub.id] = arr;
- }
- return item;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement