Implementing data manipulation
The Firebase database is bundled with lots of events, and for our Cloud Functions to function properly we're going to exploit a set of these functions that will make our lives much simpler.
As a use case, we're going to see how we can integrate Firebase Cloud Functions within an Online store. The function job here is to listen to any new-made unfinished purchase and set its status to pending state.
So, let's get to it!
Getting ready
Before you start adding your function's implementation, please make sure that your project is ready for Cloud Functions. For double check, please look at the preceding recipe for help--Getting started with Cloud Functions.
How to do it...
Once you've successfully configured your project, let's start integrating the function within our online store.
- We need to listen to our purchases collections over our Database using the
onWrite
function to any new writing operation that was made over our collection, like the following :
exports...