Firebase Fundamentals

Composite Queries Exercise

David East

David East

Google
Firebase Fundamentals

Check out a free preview of the full Firebase Fundamentals course

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

Students are instructed to write a query for all expenses not categorized as fun, clothes, gifts, home, or personal, and a query for all expenses categorized as 'food' and occurred in January 2021 but not on 12/26/2021.

Preview
Close

Transcript from the "Composite Queries Exercise" Lesson

[00:00:00]
>> We're going to dive back into our app, and we're in the same code file and everything and we're going to do a bit more complicated query. So, one thing to note too, is I mentioned that if you create a comp if you try to run a composite query We will throw an error and we say hey you need to create this in order to run this query.

[00:00:23]
That is only true for production queries when you're using the emulator., If it's running against a local emulator, we don't have to worry about scale. You're still in development, we're not gonna make you create any composite queries. And especially since that takes time to create the composite query.

[00:00:42]
And you only have a certain limit of it, we just let you run whatever composite queries you want to in the emulator and know If errors are thrown. So before you go to production, whatever composite queries that you are running against the emulator, you want to make sure that you have created for production All right, so this one.

[00:01:02]
Get all expenses between July 2021 and October 2021. So that's this one right here. So that's we can copy and paste code that is always great But we want to say is categorized as fun So I'm gonna copy the internals of this. And I'll say where category Equal, equal, to fun.

[00:01:32]
And so this right here, now becomes a composite query because this is two fields. Before is always one field, now it's more than one field. So let's save So we run it. And look at that. We have our costs, we have our costs, we have our category. Everything in the category is fun.

[00:01:53]
And if we look, this is in July. I started in July. Sorry, did I say July? I did this. There'll be tween. Yeah, we're in July. We're gonna be in July. To October.Dates are weird you know, and so we're in July and as we scroll down,yes, this isn't September and we stop at September 30th.

[00:02:15]
So this satisfies our query. Now, I want you all to see if you can tackle the last two ones. These you can use all the above code. I'll keep it on the screen. But this exercise time, we're going to get all expenses that are. Not categorized, or that I get all expenses, or you can limit, if you want, that are not categorized as fun, clothes, gifts, home and personal.

[00:02:50]
But this one will be a composite, but it's fine. This is still a good one to do. This last one is a composite.

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