How to create Typescript interface that reflects firestore structure

Asked

Viewed 22 times

1

Good morning,

I’m getting data from firebase firestore with a structure that I’m having trouble representing as a model in Typescript, that is, an interface. I made a JSON representation to illustrate the structure:

[
    {
      "20229622": [
        {
            "info": [
                {
                    "46468999": {
                        "taskName": "Project Management",
                        "totalTaskHours": "1589.4"
                    },
                    "78945556": {
                        "taskName": "Management",
                        "totalTaskHours": "988"
                    }
                }
            ],
            "done": [
                {
                    "46468999": {
                        "done": "True"
                    },
                    "78945556": {
                        "done": "False"
                    }
                }
            ]
        }

      ],
      "90220622": [
        {
            "info": [
                {
                    "46418909": {
                        "taskName": "Interface",
                        "totalTaskHours": "189"
                    },
                    "98940556": {
                        "taskName": "Backend",
                        "totalTaskHours": "90"
                    }
                }
            ],
            "done": [
                {
                    "46418909": {
                        "done": "True"
                    },
                    "98940556": {
                        "done": "False"
                    }
                }
            ]
        }
      ]
    }
  ]

My biggest difficulty is in relation to the id’s that are automatically generated numbers by the firestore. I ask you to help me create an interface that reflects this structure, or give me some hint, especially on the issue of id’s.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.