onDelete angular firestore cloud functions coding example:-
Hey guys Today I teach you onDelete firestore cloud functions.
- Why do we use the onDelete function
- How to use onDelete functions in project.
- How to deploy onDelete functions on the server.
Why do we use the onDelete function:-
You can also trigger a function when a document is deleted using the onDelete()
This example function calls onDeleteContect when a user deletes their user profile:
How to use onDelete functions in project:-
Make a file index extension called ts and write the program who describe by me-
export const onDeleteContect = functions.firestore.document('user/{uid}')
.onDelete((snap, context) => {
const data = snap.data();
consol.log(data)
return afs.collection('profiles').doc(context.params.uid).set(data || { });
});
.onDelete((snap, context) => {
const data = snap.data();
consol.log(data)
return afs.collection('profiles').doc(context.params.uid).set(data || { });
});
How to deploy onDelete functions on the server:-
After creating the cloud functions deploy on server using this command:
'firebase deploy --only functions:onDeleteContect' and after some time these operations complete successfully.
ConversionConversion EmoticonEmoticon