I have a specific use case where my database record has following data
{
id: 'user_id_1',
'26-08-23': [{...other object}],
'27-08-23': [{...another object}]
...
}
I would like to know how I can create a typescript interface to support the above case. The basic idea was to have two interfaces and see if I could extend but that doesn't work
export interface DateMappedObject {
[date: string]: UserAttendanceDateMap
}
export interface UserAttendance extends DateMappedObject {
id: string;
}
Can someone suggest a solution please?
Tldr;
Why the object is shaped this way?
- I'm using Firebase/firestore and I'm achieving two benefits with the above object The above approach allows me to get all of that data in one query
- The data is limited for each month, so the scalability issue is not a concern here)
- I'll use the dates to populate a calendar with data for a day and date-key allows quick access by index-key pattern.