I have a firebase database that looks something like this:
{
"timetables": [null,{
//first child
},{
//second child
"8": "null",
"9": null,
"10": "sleep"
} ]
}
How do I get the first non-null value after a particular key (say, "8" in the second child) ?
"9" has a null value. So, I should get the value corresponding to "10", "sleep"
How to modify my code in order to do this?
let loc = "timetables/" + datetime.getDay(); // datetime.getDay() returns a number from 0-6 which corresponds to one of the children.
var ref = db.ref(loc); // positioning reference at the appropriate child
I thought of using the below function, but wasn't able to come up with how to use it exactly:
ref.once("value",function(data) {
app.tell(REPORT_MESSAGE + data.val() + ' at ' + data.key);
});
*/
.timetables[2]
? And again, will your keys always be numerical?