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