Tuesday, 30 May 2017

How to add data to Firebase without replacing using NodeJS?

So I am trying to send a time difference between two distances from my NodeJS server to Firebase database.

function sendDatabase(dbName, payload1) {

        var timeNow = getTime();
        console.log(timeNow);
        var ref = db.ref(dbName);
        ref.set({difference:payload1});
    }

dBName = IpBBEfCob0c1GaYkvAzog9rVdKn1/

payload1 is the time difference that I want to send.

dbName is a child node in the database and I want to save payload1 as child node of dbName every single time it executes.

But every time this function executes it will just replace it and no new entry will be created. I know that this is because the property name difference is the same every time, therefore I searched on Google to see if I can make it unique so that it will not replace, but I could not find a proper answer to my issue.

I am a beginner to Firebase and help with this would be much appreciated.



via Vihanga Bandara

No comments:

Post a Comment