Chen Li Yong
Chen Li Yong

Reputation: 6107

How to properly set Firebase Realtime Database to avoid null value at the beginning of array?

I'm new to NoSQL database. Currently I'm trying to use the Firebase and integrate it with iOS. When it comes to predefine the database, with trial and error, I try to make it look like this:

enter image description here

When I tried to retrieve the "stories" path in iOS, I get json structure like this:

[
    <null>,
    {
        comments: [
            <null>,
            1,
            2,
            3
        ],
        desc: "Blue versus red in a classic battle of good versus evil and right versus wrong.",
        duration: 30,
        rating: 4.42,
        tags: [
            <null>,
            "fantasy",
            "scifi"
        title: "The Order of the Midnight Sun",
        writer: 1
        ]
    }
]

My question is, why there's always a null at the beginning of each array? What should I do in the database editor to avoid the null?

Upvotes: 0

Views: 829

Answers (1)

Mohamed Taher
Mohamed Taher

Reputation: 99

It looks like you start pushing data to index 1 and not 0, inserting/retrieving data to/from a list starts with index 0:

enter image description here

Upvotes: 2

Related Questions