Cloud Functions for Firebase: Reading the Entire Database into Memory

Viewed 457

I would like to read the entire Firebase database into a variable from inside a backend Cloud Function, as follows:

exports.transformUserData = functions.https.onRequest((request, response) => {

    admin.database().ref('/').on('value', function (snapshot) {

        var dbData = snapshot.val();
        ...

    });
    ...
});
  1. Is this safe? (From a memory or dollar cost perspective, speed is not an issue in this case).

  2. I expect the function will crash once my database grows due to an out-of-memory error. If this is the case, at what memory limit can we expect it to crash? (For example, 10MB).

Thank you in advance for any advice!

1 Answers
Related