javascript - Firebase Web update() deletes all other child nodes -
hello getting weird behaviour here. try update 1 specific child node, when user clicks button. here code:
var updates2 = {}; var offer = { minusaccandshare: 2, } updates2['/offerlight/' + keyreal] = offer; updates2['/offer/' + keyreal] = offer; return firebase.database().ref().update(updates2);
everything working fine correct nodes updated while updating minusaccandshare else deleted
the structure like:
offer jifdjsiavdas minusaccandshare: -6 offername: "replacement" offertext: "you have choice to..." ...
and becomes
offer jifdjsiavdas minusaccandshare: 2
i used approach described in firebase guides multiple times , worked charm. there created completly new nodes new key there nothing deleted.
thanks :d
what happening in code folowing:
you writing entirely key thereby wiping off whole properties in dataset.
this
updates2['/offer/' + keyreal] = offer;
wipes out whole data in particular key.
try instead:
firebase.database().ref('offer/' + keyreal).update({ minusaccandshare: 2, });
this allows make sure change specified property in firebase dataset.
i hope helped
Comments
Post a Comment