Flutter & Firebase App Tutorial #16 - Firestore Database Setup
Skills:
AI Workflow Automation60%
Key Takeaways
Sets up Firestore database and links it to a Flutter app
Full Transcript
all right there my friends so the time has come now whereby we want to start showing data in the app and by data I mean the users preferences so how strong do they like the coffee how many sugars their name etc now to do that we're going to use a database provided by firebase so go to your consult first of all consult firebase Google comm and choose your project in my case it's ninja brew crew and then click on database on the left now firebase gives us two options here they have an older database called a real time database or the newer one called a cloud fire store and this is the one we're going to use so click on create database and make sure you start in test mode and this alters the rules of your fire store so that anyone can read and write to the database if you started in locked mode then it means that we'd have to start playing around with the rules a little bit to start storing data and I don't want to do that just yet we might have a look at this later on so for now let's start in test mode and click on next so let's choose the location it doesn't really matter I'm gonna choose Europe West and go to done and this is gonna create your fire store database for you ok so once that's done you're gonna see this page and right here we have an empty fire store database now I'm not going to go into too much depth about what a fire store database is if you want to learn more from the ground up about fire store I have a complete series on this channel about fire store databases and I'll leave that link down below but basically what it does is allow us to store data and collections so we have collections for different things in our app so for example we could have collection for I don't know user data we could have a collection for books on a book website or movies on a movie website okay so it's particular types of data and we can create a new collection by clicking this button right here now in each collection we'd have a series of documents or records and each document would represent one record in that collection so say we had a collection of I don't know user data and each record each document would represent the data of one particular user right so each record or each document would look a bit like an object in programming and it would have key value pairs so for example if we had a user data collection each document would want to have several different key value pairs for example the strength of their coffee that would be a key value pair the strength would be the key and the value could be some kind of number we'd also have a name key and maybe a string as a value we'd also have a Sugar's key and a number as a value to say how many sugars that user has in their brew okay so that's the firestore database setup now we don't need to create a collection right here it's going to do that programmatically for us when we start to work with firestore in our code okay then so now we've set up the firestore database in the firebase console now we can start to use the firestore package inside our app to communicate with that database now remember we already installed that package if I go down to pub spec dots Yunel we can see right here we have the cloud fire store package so we don't need to install anything else we can just start to use it and interact with our fire store database now to do that what I'm going to do is create a new file inside the services folder so like we had a service class for authentication we're also going to have a service class for the database so let me right click this and go to new file and I'm just going to call this database dot now inside here the first thing we need to do is import that cloud fire store package so I'm gonna say import and then it's going to be fire store this one right here okay so now let's create a class called database service like so an inside here this is where we're going to have all the different methods or properties that are going to be used to interact with the firestore database now the first thing we need is something called a collection reference and it's essentially just that a reference to a particular collection in our fire store database so that if we want to then do something with that collection and have read from it add to it then we can use this collection reference so the way we do that is by first of all to claim a final property because this is not going to change its off type collection reference like so and we'll give this a name I'm going to call it the Beru collection because we're going to store brews inside this collection and then it's going to be equal to something so the thing it's gonna be equal to is a fire store instance first of all so fire store instance and we have access to this thing because we imported this package and then we can reference a specific collection inside our fire store database and that collection will be called Bruce I've made this collection name up you can call it what you want but we're going to be storing brew data in there or user data in there for each brew so I've called it Bruce okay now I know when we went to enable a fire store database a minute ago we didn't create a collection but that doesn't matter if when the time this code runs that collection doesn't exist fire stock will go ahead and create it anyway it's going to look at this and say okay it doesn't exist yet but I'll create it for you and then once it does create it thereafter it just gets a reference to that particular collection so it doesn't matter that we've not created one already it will be created behind the scenes for us and you'll see that later on so then now we have a reference to this collection and we can go ahead and do things now like add new documents to the collection we can read documents from the collection or update documents in the collection and even remove documents from the collection and we do that by using this variable now right here and we're going to start that process in the next lesson by adding a fire store record for every new user when they register
Original Description
Hey gang, in this Flutter tutorial we'll set up our Firestore database and link it to our app.
----------------------------------------
🐱💻 🐱💻 Course Links:
Course files - https://github.com/iamshaunjp/flutter-firebase
🐱💻 🐱💻 Other Related Courses:
+ Flutter Tutorial for Beginners - https://www.youtube.com/playlist?list=PL4cUxeGkcC9jLYyp2Aoh6hcWuxFDX6PBJ
+ Firebase Auth Tutorial - https://www.youtube.com/playlist?list=PL4cUxeGkcC9jUPIes_B8vRjn1_GaplOPQ
+ Firebase Firestore Tutorial - https://www.youtube.com/playlist?list=PL4cUxeGkcC9itfjle0ji1xOZ2cjRGY_WB
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Net Ninja · Net Ninja · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: AI Workflow Automation
View skill →
🎓
Tutor Explanation
DeepCamp AI