Image for post
Image for post

It’s a common pattern that every developer has programmed — iterate across a dataset, and update each record. How can we do that with Cloud Functions?

A simple example is to set the lastProcessed time with the current timestamp. Doing this in MySQL can be really simple UPDATE userTable SET lastProcessed = NOW(); but how do we do it in Firebase?

Iterative Update

An easy way to update a bunch of records is to fetch all records and update the lastProcessed property via a loop.

This can become fairly intensive. If you have 20 users you’re going to make 21 requests to the database — 1 read, 20 writes. …

About

Michael Kimpton

FinTech / Blockchain Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store