How to trigger Firestore ?

In this story we will cover trigger on firestore .We will use JavaScript for trigger firestore.

const functions = require('firebase-functions');

const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();

exports.getData = functions.https.onRequest((req, res) => {
const docRef = db.collection('collectionName).doc('document')
const getDoc = docRef.getData()
.then(doc => {
if (!doc.exists) {
console.log('No such document!');
return res.send('Not Found')
}
console.log(doc.data());
// res.status(200).json(doc.data())
return res.send(doc.data());

})
.catch(err => {
console.log('Error getting document', err);
});
});
exports.storageChanges = functions.storage.object().onArchive(event => {
return res.send(event.getData());
});

Thank you for reading this story👍👍👍👍👍