manifold/functions/src/on-fold-delete.ts

11 lines
350 B
TypeScript
Raw Normal View History

2022-01-26 20:56:15 +00:00
import * as functions from 'firebase-functions'
export const onFoldDelete = functions.firestore
.document('folds/{foldId}')
.onDelete(async (change, context) => {
const snapshot = await change.ref.collection('followers').get()
// Delete followers sub-collection.
await Promise.all(snapshot.docs.map((doc) => doc.ref.delete()))
})