Table of Contents
IntroductionDavid East introduces the course by walking through the required installations and where to find the course materials. An overview of Firebase, including the architecture, libraries, and general workflow, is also covered in this segment.
Working with Firestore DataDavid walks through connecting to a Firestore database by pulling in markdown that has been converted into HTML and discusses how working with Firestore data compares to using SQL. Setting a document, deleting a document, and receiving the results in a callback are covered in this segment.
Firebase AuthenticationDavid discusses implementing Firebase authentication using the Anonymous authentication provider, which can also provide guest authentication. Firebase Authentication is a fully managed authentication system for signing in and managing users without needing a designated server.
Setup Firebase HostingDavid demonstrates logging into and setting up the Firebase CLI to deploy web applications. A student's question regarding the difference between the doc and setDoc function is also covered in this segment.
Dev Config Best PracticesDavid discusses what went against best practices in the previous Firebase demo and briefly demonstrates implementing best practices for security, code structure, production services, deployment, and data models. A student's question regarding if Firebase sets up a WebSocket when talking to the database is also covered in this segment.
Setup Local Emulator EnvironmentDavid walks through connecting to the Auth and Firestore emulators, the contents of the firebase.json file, and enabling the Emulator UI. Student questions regarding how often the offline data store updates and caches data and if users and data can be populated in a development environment are also covered in this segment.
Firestore & NoSQL OverviewDavid provides an overview of SQL databases, translates those concepts onto NoSQL databases, and provides pros and cons for both approaches. Firestore is a NoSQL document database with real-time and offline capabilities.
Retrieving & Writing DataDavid demonstrates retrieving data from Firestore by attaching a collection or document reference to the onSnapshot method. Using mutation functions such as setDoc, updateDoc, and deleteDoc to write data, generating path Ids, and server timestamps are also covered in this segment.
Synchronization & Offline CachingDavid discusses the difficulty of incrementing data on a real-time system, avoiding update errors by utilizing generated IDs, and an overview of the offline cache. Student questions regarding if there is a limit to the number of listeners on paths and how to indicate a disconnection from Firestore are also covered in this segment.
Firestore Realtime Stream ExerciseStudents are instructed to create realtime streams and map over the data.
Firestore Realtime Stream SolutionDavid walks through the solution to the Firestore realtime stream exercise.
Querying FirestoreDavid briefly discusses simple and composite queries and walks through query operators, including equality, in, greater than, less than, and not-in. Simple queries involve querying based on one field, while composite queries involve querying based on more than one field.
Simple QueriesDavid live codes examples of simple queries, including limited queries, queries for specific categories, less than queries, and queries for data within a set date range.
Composite Queries & IndexesDavid discusses creating custom sorted composite indexes for quick database querying. Student questions regarding if there is support for or queries, if queries can be ordered by date, and if there is a way to get queries back in random order are also covered in this segment.
Composite Queries ExerciseStudents 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.
Composite Queries SolutionDavid walks through the solution to the composite queries exercise.
Map & Querying ArraysDavid walks through querying through arrays with array operators such as array-contains and array-contains-any. A more complicated example of querying a date range with set excluded dates is also demonstrated in this segment.
Range Queries & Cursoring PaginationDavid demonstrates dividing large query results into smaller discrete pages using startAt and endAt to create references to data ranges.
Denormalization & Document StructureDavid discusses the difference between joins in SQL and NoSQL databases and the hierarchy of the document structure. How to update repeated data located in multiple collections and query across all subcollections is also covered in this segment.
Collection Group Queries ExerciseDavid demonstrates the flexibility of NoSQL databases by walking through a few examples of collection group queries.
Atomic Operations & TransactionDavid discusses handling when an operation fails by making the process atomic with batched writes and transactions. Transactions run multiple operations in an atomic process including the access to reading data.
Authorization & Security
Enabling Firebase AuthenticationDavid provides an overview of Firebase Auth, a serverless authentication provider with integration into Firebase security rules. A demo walkthrough of authenticating users, linking accounts, and admin permissions is also provided in this segment.
Auth Q&ADavid answers student questions regarding what anonymous login looks like, if there are any specifications to follow to create a custom auth provider, and how to decide which kind of auth to use.
Security RulesDavid discusses Security Rules as being used to determine access to Firebase resources on every request and live codes some Security Rules. Security Rules are centralized, written in a custom language, and must match at the document level.
Authentication Security RulesDavid walks through examples demonstrating testing and writing Security Rules to determine authenticated and unauthenticated users.
Structural Security RulesDavid live codes examples of structural Security Rules, which determine that the data sent to the server is the data the server expects. A demonstration of the Firestore request monitor is also provided in this segment.
Role Based Access ControlDavid walks through examples of role-based access control Security Rules to determine a user's role and what that role has access to.
Cloud FunctionsDavid discusses functions that allow writing server code in response to events within Firebase without needing a server known as Cloud Functions. Functions are considered a trusted environment, allowing the Admin SDK to be used.
CDN Cache & HTTP RequestsDavid walks through examples demonstrating using Cloud functions to set a CDN cache for an hour and make an HTTP request. This segment also covers configuring the firebase.json file to connect to Firebase hosting.
Document TriggersDavid live codes an example of a Cloud Function triggered by a document event. Users changing their data will trigger the Cloud Function to update it across all expenses.
Admin SDKDavid walks through an advanced use case for a Cloud Function to write a request to create a subcollection, look up a user by email with the Admin SDK, and add them as collaborators.
Authentication TriggersDavid walks through a continuation of the Admin SDK example by checking if a new user has any pre-existing collaborator requests and, if so, adding them as collaborators. A brief discussion regarding the auth triggers onCreate and onDelete and the v2 blocking functions beforeCreate and beforeSignIn.