I can't find the answer to this in the documentation. I have created a firebase cloud function which listens to the database and gets triggered when a doc in the database changes.
What I want the function to do is to gather information from the database, other than the information listened to in the first place, and then work with that information. How would I gather information from the Firestore database using firebase admin?
Down below is the code I have written so far:
exports.costCalculation = functions.firestore
.document("questions/{docId}/post_publish_information/outcome_information")
.onUpdate((change, context) => {
const predictions = admin
.firestore()
.document("questions/{docId}/post_publish_information/predictions");
console.log(predictions);
});
The Admin SDK is already loaded and initialized, you just can't access it through the admin variable. If you don't feel like initializing an Admin SDK instance yourself, you can work from the document you get it from change.
For example, to get a reference to the predictions document you can also:
change.before.ref.parent.doc("predictions")