Firebase Fundamentals

Composite Queries Solution

David East

David East

Google
Firebase Fundamentals

Check out a free preview of the full Firebase Fundamentals course

The "Composite Queries Solution" Lesson is part of the full, Firebase Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:

David walks through the solution to the composite queries exercise.

Preview
Close

Transcript from the "Composite Queries Solution" Lesson

[00:00:00]
>> All right so let's take a look on how you would do that with these two queries, we're gonna get all expenses or you can limit them I don't know why I said well but it's fine. So expenses collection, where expenses are not categorized as funds. So I can say where category is not in and I wrote this almost to fit right in, except for the end.

[00:00:33]
And so now it'll be able to see this one, two, three, four, five, so it's five out of the ten that I can use for that. Usually, I'll format these down on all one per line, so it's a little more readable. For now, let's refresh and that let's see here can I remember food, clothes, gifts, home personal enough food sorry.

[00:00:58]
Fun clothes gifts home personal and yeah so ton of stuff but it's mostly food and healthcare and not housing so not those ones as we can see. So the not in operator right there helps you eliminate a bunch of stuff. Now for the more complex query. We wanna get all expenses that are categorized as food so expenses, collection, where, category is equal to food.

[00:01:31]
You also can do. In food as well, it's the same thing, this will just give you more options. So just depending on what you're trying to express and then we want to say where. Date is greater than December, thank you very much not January greater than new date or that occurred in December so that is greater than 11/31/2021.

[00:02:13]
And date is less than 1/1/2022, and now for this last one we wanna see but as not on 12/26, you can say where date I can say not equal to new date 12/26/2021. Yes, all right, save that. And as we scroll through we don't have any date for 12/26, and just to show that it would be there, because if my dataset is correct.

[00:02:54]
We have all these 26 ones when I take it out so the not equals and you can even do for multiple dates you could do not in and then provide a whole array of dates. So if imagine some calendar picker where you're trying to find certain things when someone's saying exclude these dates from my selection those would all become part of the noddin query.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now