问题描述
我正在尝试遍历孩子,但我得到 None 作为第一个键,例如应该是案件编号.
.
I am trying to iter through childs, but I get None for first key which should be e.g. id of case.
and this is result of code [None, {'-MaISrSqXnill-8W7sG1': {'datum': '22.5.2021', 'idtip_uplate': '11', 'iduplata': '1', 'novaca': '50', 'predmet': '1'}}]
For some reason he don't see first key
When you use numeric keys (like the 1
) in your data, you run the risk that Firebase will try to be helpful and interpret those keys as indexes in an array. So in your data it sees it as an array of size 2, with no element at index 0
and the -M...
element at index 1
. And that's what the output you print shows.
To prevent Firebase from interpreting the keys as an array, ensure they start with a string value. So prefix them with a short known value, like "key1"
.
For more on this, also see: Best Practices: Arrays in Firebase.
这篇关于为什么我在具有嵌套 2 个级别的 firebase 实时基础中为第一级的键获得 None的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!