oncrete angular firestore cloud functions coding example

oncreate angular firestore cloud functions coding example
oncrete angular firestore cloud functions coding example
oncrete angular firestore cloud functions coding example

hey this Er. Brijesh Kumar and today we teach you how to create firestore cloud function using typescript with firebase cloud database main function trigger name onCreate trigger copy data one collection to others collection paste code with firestore cloud functions example.


  1. firebase cloud functions environment variables
  2. write to firestore from cloud function
  3. deploy cloud firestore function on the server
  4. how to use firestore cloud functions in the project

1. firebase cloud functions environment variables:

first, run this command in your root terminal cmd: 'npm install -g firebase-tools' after this command goto your project directory and run on this command: 'firebase init functions' then follow the instruction after complete operations.


2.write to firestore from cloud function:-

make file index extension called ts and write the program who describe by me-

export const userForAdmin = functions.firestore.document('name/{uid}')
.onCreate((snap: any, context: any) => {
const data = snap.data();
return afs.collection('name1').doc(context.params.uid).set(data, { merge: true });
});

3.deploy cloud firestore functions on the server:-

after creating the cloud functions deploy in server for registration on the central function house run this command: 'firebase deploy --only functions:userForAdmin' and these operations complete successfully.


4.how to use firestore cloud functions in the project:-

when cloud functions deploy on the server after we need to use the functions which name comes to userForAdmin we need to write any data on collections name is name after data copying into the name1 collections its mean functions work successfully.
you can show your functions log into functions log section into the firebase console control panel.

thanks for reading the full document if any query please comment into the comment box.
Previous
Next Post »