Here is my code:
function saveID(sender_psid,count){
let data = new Object();
data.ID = sender_psid[count];
db.collection('users').doc('ID').set(data);
}
I am trying to add data to my firestore database. My current code does that but each time the function is called the new data replaces the old one instead of adding itself to the database. How do I fix that?
setwill write or replace data. Looks like you need to usepush.pushwill create an id for you. firebase.google.com/docs/database/admin/save-datapushis for the realtime database, not for Firestore (which OP is using because they referencecollection). but same principal!