Variables
Const autoBackupFirestore
autoBackupFirestore: CloudFunction<unknown> = functions.pubsub// [Minute (0-59)] [Hour (0-23)] [Day of the month (1-31)] [Month (1-12)] [Day of the week (0-6 Sunday to Saturday)].schedule('0 2 * * 0').timeZone('Europe/Istanbul').onRun(async context => {console.log('autoBackupFirestore is started!');return backupFirestore({}).then(value => {console.log('autoBackupFirestore is finished! result:', value);return value;}).catch(err => {console.error('autoBackupFirestore', err);return err;});})
Const db
db: Firestore = admin.firestore()
Const newMessageEn
newMessageEn: CloudFunction<QueryDocumentSnapshot> = functions// .region('europe-west1').firestore.document('messages_en-US/{messageId}')// tslint:disable-next-line:promise-function-async.onCreate((snap, context) =>sendMailForNewMessageEn(snap.data()).then(value => {console.log(value);return value;}).catch(err => {console.error('functions.onCreate', err);return err;}))
Const newMessageTr
newMessageTr: CloudFunction<QueryDocumentSnapshot> = functions// .region('europe-west1').firestore.document('messages_tr-TR/{messageId}')// tslint:disable-next-line:promise-function-async.onCreate((snap, context) =>sendMailForNewMessageTr(snap.data()).then(value => {console.log(value);return value;}).catch(err => {console.error('functions.onCreate', err);return err;}))
automatically backup firestore