Query hierarchical data structure in firebase

后端 未结 1 623
甜味超标
甜味超标 2020-12-19 20:01

I have an app that stores data in a tree structure, which I\'d like to persist to Firebase.

Each node in the tree are like this:

    node:
        si         


        
1条回答
  •  温柔的废话
    2020-12-19 20:31

    I reorganized my data structure to store the 'data' field separately, to make the tree structure small enough to fit entirely on the client side. For each node in the tree, I use the path that leads to the node as the key to store the 'data'. For example,

        root:
          2:
            0:
              3:
                size: 123
                data: [ //list of items ]
    

    is stored as:

        root:
          2:
            0:
              3:
                size: 123
        data:
          203: [ // list of items ]
    

    In this way, I can selectively load each node's data by using the path to that node as the key.

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