ONDELETE ANGULAR FIRESTORE CLOUD FUNCTIONS CODING EXAMPLE

onDelete angular firestore cloud functions coding example:-




Hey guys Today I teach  you onDelete  firestore cloud functions.

  1. Why do we use the onDelete function
  2. How to use onDelete functions in project.
  3. 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  || { });
});

How to deploy onDelete functions on the server:-

After creating the cloud functions deploy on server using this command:
 'firebase deploy --only functions:onDeleteContectand after some time these operations complete successfully.



                                                           Thanks For Reading



Previous
Next Post »