Name Firebase Child As Sequence Array
I want to use Fusionchart to read my Firebase data and create a chart in my web app. but my Firebase DB has a wrong structure, so the Fusionchart can't get data (my Firebase confi
Solution 1:
If you don't want the push ID inside your pseudo-numeric keys, call set
instead of push
.
So:
firebase.database().ref('testdata/User1').child(num).set({x:posX,y:posY,MaxSpeed:maxSpeed,steps:counter,time:Timeperiod/1000,speed:SpeedRecord,});
Your other problems seems (it's impossible to be certain, since you didn't include the code for the increment) to come from the fact that num
is a string. If that is indeed the case, increment it with:
num = String(parseInt(num) + 1);
Using such numeric keys is an antipattern in Firebase though, so I'd usually recommend against using them. If you must, at least pad them til a certain length, so that you can sort/filter on them easily.
Something as simple as:
num = String(parseInt(num) + 1).padLeft(5, "0");
Will work on all modern browsers, and ensures that all keys-that-look-like-numbers-but-behave-like-strings will show up in the order you expect.
Post a Comment for "Name Firebase Child As Sequence Array"