Why do firebase collections seem to begin with a null row?

前端 未结 2 1412
遥遥无期
遥遥无期 2021-01-01 12:32

\"firebase

I\'ve created a simple firebase data set to test some REST calls with (see the im

相关标签:
2条回答
  • 2021-01-01 13:10

    I found a hack for the above issue. Just use a non-numeric (dummy) key with all numeric keys and firebase will not convert the numeric key to null when you export. Please check the screen-shot for better understanding. I have used 'd' with other numeric keys, even though i am not using key 'd'.

    0 讨论(0)
  • 2021-01-01 13:16

    Firebase automatically detects when an object 'looks like' an array, and converts it accordingly. Since 'systems' and 'system_types' have children of 1, 2, and 3, Firebase is automatically converting these to arrays at output time. However, since you didn't specify a value for index 0, Firebase is just inserting an empty element.

    I'd suggest either using zero-based ID's, or perhaps starting your id's with something non-numeric so we know it's not an array (ie: item1, item2, item3).

    You could also just ignore the null element -- In Firebase null and non-existent are the same thing.

    0 讨论(0)
提交回复
热议问题