Umar Hussain
Umar Hussain

Reputation: 3527

Firebase functions not triggered on Database write

I have this firebase function which is properly deployed for testing on Firebase :

exports.testDataPoint = functions.database.ref('/testDataPoint/{uid}/{id}/')
    .onCreate(event => {
        if (event.data.exists()) {
            return admin.database().ref("/test/"+event.params.uid+"/accumulate")
            .transaction(current => {
                return (current || 0) + event.data.val();
            })
        }
        else{
            return Promise.resolve(true)
        }
    });

When I try to write a data of 10000 entries at once the function is not triggered at all. But if the number of entries is around 1000, function triggers perfectly. Here is the script I'm using to write data:

function testGroupWrites() {
    let users = {};
    for (let i = 0; i < 1000; i++) {
        let id = shortId.generate();
        let jobs = {};
        for (let j = 0; j < 10; j++) {
            let uid = shortId.generate();
            console.log(uid);
            jobs[uid] = 1;
        }
        users[id] = jobs;
    }
    db.ref("testDataPoint")
        .set(users)
        .then(() => {
            console.log("written");
        })
}

Is there any limit to how much data can be written at a point above which function will not gets triggered? I'm testing this scenario, because in my project firebase function will be doing the same thing to calculate values. I'm using Admin SDK in my script to write dummy data.

Upvotes: 0

Views: 514

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80904

Yes there is a limit, please check the below:

enter image description here

So the maximum is 1000 entries, more info here: https://firebase.google.com/docs/database/usage/limits

Upvotes: 3

Related Questions