0

I have a list with the following data: (List of halls, every hall has some events that start at a given time and end at a different time)

{
    name: "hall 1"
    events: [
        {
            name: "React lecture",
            startAt: 1500225422,
            endAt: 1500226422
        }
    ]
}, {
    name: "hall 2"
    events: [
        {
            name: "Angular lecture",
            startAt: 1500227422,
            endAt: 1500228422
        }
    ]
}

I would like to query all of the events, and their halls, to see what event is currently happens and where.

Given a current timestamp (lets say 1500225556), I would like to get:

{
    name: "hall 1"
    events: [
        {
            name: "React lecture",
            startAt: 1500225422,
            endAt: 1500226422
        }
    ]
}

If necessary, I can flatten this a bit, and have a list of halls, and a list of events with a reference to the hall they take place at.

SQL equivalent (list): WHERE startAt < 1500225556 AND endAt > 1500225556

I cannot think of a solution without a custom cloud function.

Amit
  • 5,924
  • 7
  • 46
  • 94
  • _If necessary, I can flatten this a bit, a list of events with a reference to the hall_ This is how you have to do it in a NoSQL database like Firebase. – Thomas Jul 16 '17 at 18:01
  • Yeah, but if I have that list of events, how do I filter 2 paramters. I know I know how to do either `startAt < 1500225556` or `endAt > 1500225556` but not both. Any insight on that? – Amit Jul 16 '17 at 18:02
  • 1
    Then your q was a bit unclear / verbose. Unfortunately you can't use two keys, see this q: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Thomas Jul 16 '17 at 18:05

0 Answers0