We're working on an app that makes use of Firebase Firestore. Every day, at midnight, we'd like to set the value of a counter property to 1 for every User document in a collection.
Cloud functions seemed like a reasonable choice for this, and we quickly found a means to schedule Cloud Functions:
exports.incrementCounterNightly = functions.pubsub.schedule('0 0 * * *')
.timeZone('Europe/London')
.onRun((context) => {
console.log('This will be run every day at 00:00 AM London Time!');
});
The path to the documents we'd like to write to is collections/users/*.
Our questions are:
- What's the best means to achieve this within Cloud Functions?
- Is this something Cloud Functions can suitably achieve?
- Is this scalable? What if the users collection grows to 100,000, or even 5,000,000 documents?
Many thanks in advance,
Ed