Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup

Net Ninja · Intermediate ·🛠️ AI Tools & Apps ·8y ago

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.
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 44 of 60

1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

This video shows how to set 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.

Key Takeaways
  1. Create a new Firebase project in the Firebase Console
  2. Set up a Firestore database in the Firebase Console
  3. Initialize the Firebase application in the Vue.js project
  4. Export the Firestore database reference
  5. Install the Firebase SDK using NPM
  6. Import the Firebase SDK in the Vue.js project
  7. Update the Firestore API settings to fix an error (if necessary)
💡 The Firestore API has been updated to include a new timestamp class, which may cause an error in the browser console if not properly configured.

Related Reads

Up next
How to Get Your Brand Cited by ChatGPT, Claude and Gemini
Arvow
Watch →