Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Key Takeaways
The video demonstrates setting up a Firestore database in a Vue.js project using Firebase, including initializing the Firebase application and exporting the Firestore database reference. The instructor also provides an update on a recent change to the Firestore API and shows how to fix an error that may occur due to this change.
Full Transcript
so in the West project we hooked up our application with firebase midway through but that's because I was easing those into the project now I actually think it's a good idea to set up our database from the beginning and get our app hooked up to it from the offset so then we don't have to start worrying about it later on when we come to use it so first of all let's go to our console so that's it consult up firebase google.com you can also get to it by clicking console in the top right when you go to the firebase website and we'll add a new project so first of all the name of this project is gonna be udemy - ninja - chat you can call it whatever you want choose your country or region and create that project ok so now he's created we'll go to our control panel and we'll set up our database over here so click on database first of all and inside here we'll choose the firestore option which is over here on the left get started and we'll start it in test mode again an able okay cool and now we have our firestore instance setup so we can now use it in our project now we want to set up a configuration file inside our project where we're initializing our firebase application on the front end so to do that let's go back to our project overview first of all and click on this option where we want to add firebase to our web app so once this loads we want to grab this stuff right here again inside this script tag and copy that remember we load in the firebase library via NPM not via this script right here so we'll cross that off and head over to our code editor now and then go into source and create a new folder inside here and this folder will be called firebase and in here we'll create a new file called in it is to initialize our firebase project now first of all we'll paste in this stuff we just copied now we don't yet have firebase installed so we'll need to install that down here in the terminal now make sure you're inside the ninja chat directory the root directory of our entire project here then we'll say npm install firebase and if you have a early version of npm you'll need to do double dash save to save that to your dependencies all right so now that's installed what we can do is import it up here at the top of the file so we'll say import firebase from and it's firebase so we needed that because we're using firebase down here to initialize our app we're also going to store this in a constant called firebase app you can call this constant whatever you want by the way it just makes sense to call it five eight up to me and then underneath this we need to export something now we want to export our database which is going to use the firestore method so first of all we'll need to import firestore at the top import firestore from firebase forward slash fire store so now we can come down here and say exports default and we want to export the firebase app up here which is our initialized up then we want to say dot fire store because we're exporting our fire store database reference okay now we've exported it there we can use it inside our other components in a future lessons hey gang gets shown here from the future with a quick update because since recording these videos the firebase team have updated the firestore API slightly and they've done that to add a new timestamp class to represent timestamp fields in the database now by doing that the knock-on effect is that we get a big fat red error in our browser console now you may have seen this you may have not seen this it depends on which version of firebase you have installed in your application if you have version 4.1 three and above you probably will see this error if we ever tried to use the firestore if you have something below that you probably won't either way all we need to do to get rid of that error is add in one line of code inside this initialization file image is where we initialize our fire store application so where we see constabies up equals firebase dot initialize app and then inside config we want to come below that then paste in this line of code we take the firebase up then we get the firestore dot settings and inside the settings function you pass in this one object now inside this object we pass in one property and that property is timestamp in snapshots camelcase and we set that equal to true so by doing this we're going to get rid of that big error that we see in the console every time we try to use the firestore now this code is not going to have any effect on any of the other code that we write inside this project or any of the other projects we do in this series but it is going to get rid of that error if you were seeing it
Original Description
FULL COURSE LINK - https://www.udemy.com/build-web-apps-with-vuejs-firebase/?couponCode=NINJAYT18
Use Code NINJAYT18 for discount. Discount should already be applied when using the link above!
See the full course for a full Vue.js tutorial, including building 3 projects with Firebase.
Playlist
Uploads from Net Ninja · Net Ninja · 44 of 60
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
▶
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
🎓
Tutor Explanation
DeepCamp AI