Получить элемент от ребенка с помощью Firebase

Используйте % оператор для создания модуля:

notes[note % len(notes)]

Демонстрация:

>>> notes = ["a", "a#", "b", "c", "c#", "d", "e", "f", "f#", "g", "g#"]
>>> note = 21
>>> notes[note % len(notes)]
'g#'

или в цикле:

>>> for note in range(22):
...     print notes[note % len(notes)],
... 
a a# b c c# d e f f# g g# a a# b c c# d e f f# g g#

0
задан Renaud Tarnec 5 March 2019 в 15:38
поделиться

1 ответ

Следующее должно сделать трюк:

        var userQuery = firebase.database().ref('users').orderByChild('rank').equalTo(4);
        userQuery.once('value', function(snapshot) {
            snapshot.forEach(function(childSnapshot) {
              var childKey = childSnapshot.key;
              var childData = childSnapshot.val();
              console.log(childKey);
              console.log(childData);
           });
        });

Посмотрите документ здесь: данные # listen_for_value_events

0
ответ дан Renaud Tarnec 5 March 2019 в 15:38
поделиться
Другие вопросы по тегам:

Похожие вопросы: