4

I'm newbie on cloud function. I have some confusions.

  1. Is there any difference between admin.firestore and functions.firestore?
  2. Is admin.database for real-time database?
  3. So if cloud functions are basically written as JavaScript or TypeScript in Node.js environment, then I can write them with JavaScript. But documentation made me confused about that. Because whenever I read the documentation, it gives things different. For example,

Cloud Firestore triggers-> onWrite Above code to get a document, it uses document('some/doc'). enter image description here But, above code it uses doc('doc') to achieve the same functionality. If all of them come form firestore, why do both differ each other?

Can someone help me to understand these questions? Thank you for all your supports.

1 Answers1

3

functions.firestore: is used to set up a trigger. You can set up a listener on a document path so that whenever an event happens on that document (create/update/delete etc.), this function will be executed. See how to create one here.

admin.firestore: is used to create a reference to a firestore database. You can perform various operations on firestore collection/documents using admin sdk through that reference. See documentation.

AsifM
  • 680
  • 9
  • 21