title
Build a Node.js App With Sequelize [1] - Connection & Model
description
In this series we will create a simple job find app using Node.js with Sequelize which is an ORM for relational databases like MySQL, PostgreSQL, etc. We will be using Postgres in this series.
Code:
https://github.com/bradtraversy/codegig
HTML Template Download:
https://traversymedia.com/downloads/codegig_html.zip
💖 Become a Patron: Show support & get perks!
http://www.patreon.com/traversymedia
Website & Udemy Courses
http://www.traversymedia.com
Follow Traversy Media:
https://www.facebook.com/traversymedia
https://www.twitter.com/traversymedia
https://www.instagram.com/traversymedia
detail
{'title': 'Build a Node.js App With Sequelize [1] - Connection & Model', 'heatmap': [], 'summary': 'This tutorial series covers building a node.js app with sequelize, including creating a database and table for gigs, setting up a node.js server and dependencies, implementing sequelize database connection, and setting up web routes and database in node.js.', 'chapters': [{'end': 142.756, 'segs': [{'end': 36.965, 'src': 'embed', 'start': 7.185, 'weight': 0, 'content': [{'end': 8.146, 'text': "Hey, what's going on, guys?", 'start': 7.185, 'duration': 0.961}, {'end': 18.132, 'text': "In this series, we're going to be building an application using Node.js Express and SQLize, which is an ORM that works with any relational database,", 'start': 8.186, 'duration': 9.946}, {'end': 20.214, 'text': 'such as MySQL Postgres.', 'start': 18.132, 'duration': 2.082}, {'end': 21.855, 'text': "I shouldn't say any.", 'start': 21.174, 'duration': 0.681}, {'end': 25.817, 'text': 'It works with MySQL, Postgres, SQLite, and Microsoft SQL.', 'start': 21.895, 'duration': 3.922}, {'end': 31.421, 'text': "All right, so we're going to be using Postgres, but you can just as well use any of the others.", 'start': 25.958, 'duration': 5.463}, {'end': 36.965, 'text': 'I actually created this application on a Windows machine using MySQL with XAMPP.', 'start': 31.501, 'duration': 5.464}], 'summary': 'Building an application using node.js express and sqlize, compatible with mysql, postgres, sqlite, and microsoft sql.', 'duration': 29.78, 'max_score': 7.185, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM07185.jpg'}, {'end': 96.824, 'src': 'embed', 'start': 57.236, 'weight': 1, 'content': [{'end': 63.44, 'text': 'And I want to click on the Download Installer, and I just grab the version 11.1 installer.', 'start': 57.236, 'duration': 6.204}, {'end': 65.781, 'text': 'Okay, you can also download it for Windows if you want.', 'start': 63.46, 'duration': 2.321}, {'end': 74.59, 'text': 'And this should come with PG Admin, which is an admin tool similar to how PHP My Admin works with MySQL.', 'start': 66.261, 'duration': 8.329}, {'end': 77.753, 'text': "So again, either if you want to use either, that's fine.", 'start': 75.171, 'duration': 2.582}, {'end': 84.661, 'text': "And I just want to show you, I don't have the full application built on this machine, but I do have the HTML template.", 'start': 78.775, 'duration': 5.886}, {'end': 86.681, 'text': 'So I want it to look decent.', 'start': 85.161, 'duration': 1.52}, {'end': 95.403, 'text': "So I'm including this code gig HTML folder as a download in the description for you guys, if you're going to follow along,", 'start': 86.881, 'duration': 8.522}, {'end': 96.824, 'text': "because you're going to need the interface.", 'start': 95.403, 'duration': 1.421}], 'summary': 'Download the version 11.1 installer with pg admin for windows. html template included for interface.', 'duration': 39.588, 'max_score': 57.236, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM057236.jpg'}], 'start': 7.185, 'title': 'Building applications with node.js, express, and sqlize', 'summary': "Delves into the process of building an application using node.js, express, and sqlize, highlighting the utilization of postgres as the database, along with instructions for downloading and configuring postgres and sharing an html template for the application's interface.", 'chapters': [{'end': 142.756, 'start': 7.185, 'title': 'Building application with node.js, express, and sqlize', 'summary': "Discusses building an application using node.js express and sqlize, emphasizing the use of postgres as the database, along with providing guidance on downloading and setting up postgres as well as sharing an html template for the application's interface.", 'duration': 135.571, 'highlights': ['The chapter focuses on building an application using Node.js Express and SQLize with an emphasis on using Postgres as the database. It mentions the usage of Node.js Express and SQLize for application development and emphasizes the choice of Postgres as the database over other options like MySQL, SQLite, and Microsoft SQL.', 'Guidance on downloading and setting up Postgres is provided, with instructions on obtaining the installer from postgresql.org and accessing PG Admin. The chapter provides guidance on downloading Postgres from postgresql.org, particularly mentioning the version 11.1 installer, and highlights the availability of PG Admin as an admin tool.', "An HTML template for the application's interface, including the homepage and all gigs page, is shared for download, enabling users to have the necessary interface for following along. The chapter offers an HTML template download for the application's interface, presenting the homepage with a search box and the all gigs page, which lists gigs with title, description, and budget, along with functionality to apply and add gigs."]}], 'duration': 135.571, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM07185.jpg', 'highlights': ['The chapter focuses on building an application using Node.js Express and SQLize with an emphasis on using Postgres as the database.', 'Guidance on downloading and setting up Postgres is provided, with instructions on obtaining the installer from postgresql.org and accessing PG Admin.', "An HTML template for the application's interface, including the homepage and all gigs page, is shared for download, enabling users to have the necessary interface for following along."]}, {'end': 342.582, 'segs': [{'end': 188.212, 'src': 'embed', 'start': 142.756, 'weight': 0, 'content': [{'end': 148.919, 'text': 'so if you guys already know how to do that, then you may want to implement that yourselves, but i may do it later on.', 'start': 142.756, 'duration': 6.163}, {'end': 151.94, 'text': "but for now we're going to just kind of get this functionality going.", 'start': 148.919, 'duration': 3.021}, {'end': 156.681, 'text': 'So first thing I want to do is create our database and our one table.', 'start': 152.8, 'duration': 3.881}, {'end': 160.562, 'text': "We're just going to have a gigs table and you can do that however you want.", 'start': 156.721, 'duration': 3.841}, {'end': 166.523, 'text': "If you're using my SQL, you might want to use PHP, my admin, or you can use the terminal or some other program.", 'start': 160.602, 'duration': 5.921}, {'end': 172.265, 'text': "I'm using PG admin, so I'm just going to go over to databases here and say create database.", 'start': 166.543, 'duration': 5.722}, {'end': 174.405, 'text': "I'm going to call this code gig.", 'start': 172.865, 'duration': 1.54}, {'end': 177.166, 'text': "I'll use the Postgres user.", 'start': 175.726, 'duration': 1.44}, {'end': 182.331, 'text': "All right, so let's now go to our code gig database.", 'start': 179.13, 'duration': 3.201}, {'end': 188.212, 'text': "We want to go to schemas and let's go to tables and create table.", 'start': 182.351, 'duration': 5.861}], 'summary': 'Creating a database and a table for gigs using pg admin and postgres user.', 'duration': 45.456, 'max_score': 142.756, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0142756.jpg'}, {'end': 254.067, 'src': 'embed', 'start': 215.04, 'weight': 4, 'content': [{'end': 220.744, 'text': "And if you're using MySQL, just create an int and give it auto increment in primary key.", 'start': 215.04, 'duration': 5.704}, {'end': 223.445, 'text': 'Next one is going to be the title.', 'start': 221.724, 'duration': 1.721}, {'end': 229.989, 'text': "And we're going to use a varying character or character varying.", 'start': 224.006, 'duration': 5.983}, {'end': 237.32, 'text': "And for title, for length, let's do 200.", 'start': 231.73, 'duration': 5.59}, {'end': 240.101, 'text': 'We also want technologies.', 'start': 237.32, 'duration': 2.781}, {'end': 244.163, 'text': 'Technologies, same thing.', 'start': 242.762, 'duration': 1.401}, {'end': 248.385, 'text': "We're going to do character varying.", 'start': 244.183, 'duration': 4.202}, {'end': 252.546, 'text': "And as far as length, let's do 100.", 'start': 250.686, 'duration': 1.86}, {'end': 254.067, 'text': "No, we'll do 200.", 'start': 252.546, 'duration': 1.521}], 'summary': 'Create mysql table with int auto increment primary key, title as varying character(200), and technologies as varying character(200)', 'duration': 39.027, 'max_score': 215.04, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0215040.jpg'}, {'end': 342.582, 'src': 'embed', 'start': 304.358, 'weight': 3, 'content': [{'end': 318.905, 'text': 'so we want created at spell, just like that camel case, and this is going to be a date field, and then we also want an updated at.', 'start': 304.358, 'duration': 14.547}, {'end': 325.45, 'text': "so let's create that updated at And that will be date as well.", 'start': 318.905, 'duration': 6.545}, {'end': 328.132, 'text': 'And that should do it.', 'start': 327.331, 'duration': 0.801}, {'end': 328.973, 'text': "Let's go ahead.", 'start': 328.252, 'duration': 0.721}, {'end': 330.374, 'text': 'Actually, let me just check.', 'start': 328.993, 'duration': 1.381}, {'end': 334.657, 'text': 'Yeah, I think that should do it.', 'start': 333.256, 'duration': 1.401}, {'end': 335.557, 'text': "Let's click save.", 'start': 334.717, 'duration': 0.84}, {'end': 342.582, 'text': 'And now we have our database, we have our gigs table with all of our columns.', 'start': 337.418, 'duration': 5.164}], 'summary': 'Created date and updated date fields for gigs table.', 'duration': 38.224, 'max_score': 304.358, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0304358.jpg'}], 'start': 142.756, 'title': 'Setting up a database and table for gigs', 'summary': "Covers the creation of a database named 'code gig' and a table to store gig information using pg admin. it also outlines the process of creating a database table for gigs, specifying column names, data types, and lengths, and covers the creation of date fields for 'created at' and 'updated at' while focusing on using postgres and mysql.", 'chapters': [{'end': 188.212, 'start': 142.756, 'title': 'Setting up database and table for gigs', 'summary': "Focuses on creating a database named 'code gig' using pg admin and creating a table within the database to store gig information.", 'duration': 45.456, 'highlights': ["The chapter demonstrates creating a database named 'code gig' using PG admin and Postgres user.", "The chapter emphasizes the importance of creating a table within the 'code gig' database to store gig details."]}, {'end': 342.582, 'start': 189.333, 'title': 'Setting up a database table for gigs', 'summary': "Outlines the process of creating a database table for gigs, specifying the column names, data types, and lengths for each field, including details for primary and foreign keys, with a focus on using postgres and mysql. it also covers the creation of date fields for 'created at' and 'updated at'.", 'duration': 153.249, 'highlights': ['The chapter details the process of creating a database table for gigs, specifying the column names, data types, and lengths for each field, including details for primary and foreign keys, with a focus on using Postgres and MySQL (relevant)', 'It explains the usage of different data types such as serial, varying character, and text for the columns, with specific length assignments for each (informative)', "The creation of 'created at' and 'updated at' date fields is highlighted as essential for the table structure (informative)"]}], 'duration': 199.826, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0142756.jpg', 'highlights': ['The chapter details the process of creating a database table for gigs, specifying the column names, data types, and lengths for each field, including details for primary and foreign keys, with a focus on using Postgres and MySQL (relevant)', "The chapter demonstrates creating a database named 'code gig' using PG admin and Postgres user (relevant)", "The chapter emphasizes the importance of creating a table within the 'code gig' database to store gig details (relevant)", "The creation of 'created at' and 'updated at' date fields is highlighted as essential for the table structure (informative)", 'It explains the usage of different data types such as serial, varying character, and text for the columns, with specific length assignments for each (informative)']}, {'end': 640.243, 'segs': [{'end': 375.138, 'src': 'embed', 'start': 342.902, 'weight': 2, 'content': [{'end': 344.163, 'text': 'OK All right.', 'start': 342.902, 'duration': 1.261}, {'end': 346.785, 'text': 'So now we can actually start to create our application.', 'start': 344.223, 'duration': 2.562}, {'end': 350.167, 'text': "So let's jump into V.S.", 'start': 348.806, 'duration': 1.361}, {'end': 353.809, 'text': 'code and I just have an empty folder called code gig.', 'start': 350.227, 'duration': 3.582}, {'end': 356.21, 'text': 'And first thing we want to do is in our terminal.', 'start': 354.069, 'duration': 2.141}, {'end': 357.831, 'text': "I'm using my integrated V.S.", 'start': 356.25, 'duration': 1.581}, {'end': 358.591, 'text': 'code terminal.', 'start': 357.871, 'duration': 0.72}, {'end': 363.373, 'text': "I'm going to do NPM init so that we can create a package dot Jason file.", 'start': 359.151, 'duration': 4.222}, {'end': 365.755, 'text': "So we're going to enter through this for a description.", 'start': 363.413, 'duration': 2.342}, {'end': 366.775, 'text': "We'll just say simple.", 'start': 365.775, 'duration': 1}, {'end': 375.138, 'text': 'job find app for coders and the entry point is going to be app dot J.S.', 'start': 369.014, 'duration': 6.124}], 'summary': 'Creating a job find app using npm init in vs code.', 'duration': 32.236, 'max_score': 342.902, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0342902.jpg'}, {'end': 562.102, 'src': 'embed', 'start': 472.688, 'weight': 0, 'content': [{'end': 481.854, 'text': "OK And as a lot of you guys know node mon is it'll constantly refresh the server when we make a change so we don't have to do it manually.", 'start': 472.688, 'duration': 9.166}, {'end': 487.671, 'text': "And then once that's installed, we just want to add a couple scripts here.", 'start': 483.266, 'duration': 4.405}, {'end': 495.901, 'text': "One is going to be our regular start script, which is just going to run node, and it's going to run the app.js file.", 'start': 488.052, 'duration': 7.849}, {'end': 502.67, 'text': "All right, and then we want a nodemon app.js, and we're going to call this dev.", 'start': 496.522, 'duration': 6.148}, {'end': 507.624, 'text': 'so that we can do NPM run dev, and that will start up our server with nodemon.', 'start': 503.362, 'duration': 4.262}, {'end': 512.726, 'text': "All right, so now we can close that up and let's create a file called app.js.", 'start': 508.384, 'duration': 4.342}, {'end': 516.268, 'text': 'So this is obviously our entry point.', 'start': 514.327, 'duration': 1.941}, {'end': 519.409, 'text': "We're going to go ahead and bring in some stuff here.", 'start': 516.788, 'duration': 2.621}, {'end': 520.95, 'text': 'We need to bring in express.', 'start': 519.65, 'duration': 1.3}, {'end': 530.595, 'text': 'And we need to bring in a couple other things like express dash handlebars.', 'start': 525.312, 'duration': 5.283}, {'end': 537.97, 'text': "Let's call this EXPHBS for express handlebars.", 'start': 533.367, 'duration': 4.603}, {'end': 546.294, 'text': 'We also want to bring in our body parser.', 'start': 538.77, 'duration': 7.524}, {'end': 549.716, 'text': "We also want to bring in the path module, which we didn't install.", 'start': 546.334, 'duration': 3.382}, {'end': 554.038, 'text': "That's actually a core Node.js module just to deal with file paths.", 'start': 549.756, 'duration': 4.282}, {'end': 559.761, 'text': "Let's create our app variable and set that to express.", 'start': 555.739, 'duration': 4.022}, {'end': 562.102, 'text': 'We want to initialize our app.', 'start': 560.001, 'duration': 2.101}], 'summary': 'Using nodemon to automatically refresh the server and creating necessary scripts for server startup.', 'duration': 89.414, 'max_score': 472.688, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0472688.jpg'}], 'start': 342.902, 'title': 'Setting up node.js server and dependencies', 'summary': 'Covers the setup of a node.js server, installation of postgres, pg and pg-hstore, and the addition of dev dependency nodemon for automatic server refresh. it also includes the creation of an entry point app.js and setting up an index route for the server.', 'chapters': [{'end': 418.814, 'start': 342.902, 'title': 'Creating job finding app with node.js', 'summary': 'Covers setting up a node.js application in vs code, initializing the package.json file, and installing necessary dependencies like express, body-parser, and sequelize.', 'duration': 75.912, 'highlights': ['Installing necessary dependencies like Express, body-parser, and sequelize. The chapter covers setting up a Node.js application in VS Code, initializing the package.json file, and installing necessary dependencies like Express, body-parser, and sequelize.', 'Initializing the package.json file using npm init and specifying package details like description, entry point, author, and license. The chapter covers setting up a Node.js application in VS Code, initializing the package.json file, and installing necessary dependencies like Express, body-parser, and sequelize.', 'Setting up a Node.js application in VS Code and creating an empty folder called code gig. The chapter covers setting up a Node.js application in VS Code, initializing the package.json file, and installing necessary dependencies like Express, body-parser, and sequelize.']}, {'end': 640.243, 'start': 419.274, 'title': 'Setting up node.js server and dependencies', 'summary': 'Covers the setup of a node.js server, installation of postgres, pg and pg-hstore, and the addition of dev dependency nodemon for automatic server refresh. it also includes the creation of an entry point app.js and setting up an index route for the server.', 'duration': 220.969, 'highlights': ['The chapter covers the setup of a Node.js server, installation of Postgres, PG and PG-Hstore, and the addition of dev dependency nodemon for automatic server refresh. Node.js, Postgres, PG, PG-Hstore, nodemon', 'Creation of an entry point app.js and setting up an index route for the server. app.js, index route', 'Installation of express-handlebars, body parser, and the path module for file paths. express-handlebars, body parser, path module']}], 'duration': 297.341, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0342902.jpg', 'highlights': ['Covers the setup of a Node.js server, installation of Postgres, PG and PG-Hstore, and the addition of dev dependency nodemon for automatic server refresh.', 'Creation of an entry point app.js and setting up an index route for the server.', 'Initializing the package.json file using npm init and specifying package details like description, entry point, author, and license.', 'Installing necessary dependencies like Express, body-parser, and sequelize.', 'Setting up a Node.js application in VS Code and creating an empty folder called code gig.']}, {'end': 1029.252, 'segs': [{'end': 728.6, 'src': 'embed', 'start': 700.242, 'weight': 0, 'content': [{'end': 705.045, 'text': 'We need to put in our database name, which is going to be what do they call it? Code gig.', 'start': 700.242, 'duration': 4.803}, {'end': 709.028, 'text': 'The username is going to be Postgres.', 'start': 705.065, 'duration': 3.963}, {'end': 713.571, 'text': "That's what I used in my password for Postgres is just one through six.", 'start': 709.648, 'duration': 3.923}, {'end': 717.614, 'text': "I'm actually going to call this DB instead of sequel eyes, though.", 'start': 714.652, 'duration': 2.962}, {'end': 721.014, 'text': "and let's see, host is local host.", 'start': 719.092, 'duration': 1.922}, {'end': 721.975, 'text': 'now dialect.', 'start': 721.014, 'duration': 0.961}, {'end': 724.297, 'text': "since i'm using postgres, that's what i'm going to use.", 'start': 721.975, 'duration': 2.322}, {'end': 728.6, 'text': "but if you're using one of these other ones, make sure that you choose the correct one.", 'start': 724.297, 'duration': 4.303}], 'summary': 'Configuring a database with the name codegig, username postgres, and password 1-6.', 'duration': 28.358, 'max_score': 700.242, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0700242.jpg'}, {'end': 781.046, 'src': 'embed', 'start': 749.36, 'weight': 5, 'content': [{'end': 755.622, 'text': 'We should be able to do that by taking our DB and calling authenticate, which returns a promise.', 'start': 749.36, 'duration': 6.262}, {'end': 757.683, 'text': 'So we just want to do dot then.', 'start': 755.942, 'duration': 1.741}, {'end': 768.028, 'text': "And if it if it successfully connects, let's just say database connected.", 'start': 758.704, 'duration': 9.324}, {'end': 774.203, 'text': "OK, and then if there's if something goes wrong, it'll run the catch with the error.", 'start': 769.801, 'duration': 4.402}, {'end': 776.124, 'text': "And if there's an error.", 'start': 774.223, 'duration': 1.901}, {'end': 781.046, 'text': "Let's just oops, I forgot the console log.", 'start': 778.525, 'duration': 2.521}], 'summary': 'Authenticate db call returns promise for connection status and error handling.', 'duration': 31.686, 'max_score': 749.36, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0749360.jpg'}, {'end': 846.899, 'src': 'embed', 'start': 815.809, 'weight': 4, 'content': [{'end': 817.791, 'text': "So, like I said, I don't want to keep this in here.", 'start': 815.809, 'duration': 1.982}, {'end': 821.213, 'text': 'This really clutters up our app.js file.', 'start': 817.831, 'duration': 3.382}, {'end': 824.356, 'text': "So, what I'm going to do is create a folder called config.", 'start': 821.574, 'duration': 2.782}, {'end': 830.14, 'text': "And inside there, I'll create a file called database.js.", 'start': 825.777, 'duration': 4.363}, {'end': 835.224, 'text': 'And I want to move everything that we just did.', 'start': 831.421, 'duration': 3.803}, {'end': 838.446, 'text': 'So, bringing in SQLize, creating the database.', 'start': 835.764, 'duration': 2.682}, {'end': 841.608, 'text': 'I guess..', 'start': 841.408, 'duration': 0.2}, {'end': 845.297, 'text': "We'll leave the test in here, I guess.", 'start': 843.476, 'duration': 1.821}, {'end': 846.899, 'text': "But let's grab the rest of this stuff.", 'start': 845.317, 'duration': 1.582}], 'summary': "Creating a folder 'config' and moving database related code to 'database.js'", 'duration': 31.09, 'max_score': 815.809, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0815809.jpg'}, {'end': 995.07, 'src': 'embed', 'start': 966.062, 'weight': 1, 'content': [{'end': 976.305, 'text': "And to create a model, we're going to create a variable called gig and we're going to set this to DB dot define and we're going to call this gig.", 'start': 966.062, 'duration': 10.243}, {'end': 979.106, 'text': 'And then the second parameter is going to be an object.', 'start': 976.845, 'duration': 2.261}, {'end': 981.486, 'text': "It's going to be an object of fields.", 'start': 979.686, 'duration': 1.8}, {'end': 984.107, 'text': 'OK, very similar to how Mongoose works.', 'start': 981.506, 'duration': 2.601}, {'end': 988.408, 'text': "So we're going to have a title and it's going to have a type.", 'start': 984.747, 'duration': 3.661}, {'end': 995.07, 'text': 'OK, the type is going to be sequelize dot string.', 'start': 988.428, 'duration': 6.642}], 'summary': "Creating a model with a variable 'gig' set to db.define, with a title field of type sequelize.string.", 'duration': 29.008, 'max_score': 966.062, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0966062.jpg'}], 'start': 641.063, 'title': 'Implementing sequelize database connection', 'summary': "Discusses setting up a database connection using sequelize, configuring the host as local host, initializing a database named 'code gig', setting the username as 'postgres', and creating a model for a resource called gig with specific fields.", 'chapters': [{'end': 748.739, 'start': 641.063, 'title': 'Implementing database connection with sequelize', 'summary': "Discusses implementing a database connection using sequelize, where the host is set to local host, the database name is 'code gig', the username is 'postgres', and the password for postgres is '123456'.", 'duration': 107.676, 'highlights': ['Setting up a connection with Sequelize involves creating a variable and setting it to new Sequelize, passing the necessary database connection details, such as database name, username, password, host, and dialect.', "The database name used is 'Code gig', the username is 'Postgres', and the password for Postgres is '123456'.", 'The host is set to local host, and the dialect used is postgres.']}, {'end': 1029.252, 'start': 749.36, 'title': 'Database connection and model creation', 'summary': 'Discusses setting up a database connection using sequelize, moving the database configuration to a separate file, and creating a model for a resource called gig, with the fields title, technologies, description, budget, and contact email.', 'duration': 279.892, 'highlights': ['Setting up a database connection using Sequelize The speaker explains the process of connecting to a database using Sequelize, calling the authenticate method, and handling successful and error scenarios.', "Moving the database configuration to a separate file The chapter demonstrates the organization of code by creating a separate file 'database.js' within a 'config' folder to contain the database configuration, and then exporting it for access in other files.", "Creating a model for a resource called gig The speaker outlines the creation of a model for a resource called gig, using Sequelize's define method to specify fields such as title, technologies, description, budget, and contact email."]}], 'duration': 388.189, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM0641063.jpg', 'highlights': ["The database name used is 'Code gig', the username is 'Postgres', and the password for Postgres is '123456'.", 'Setting up a connection with Sequelize involves creating a variable and setting it to new Sequelize, passing the necessary database connection details, such as database name, username, password, host, and dialect.', 'The host is set to local host, and the dialect used is postgres.', "Creating a model for a resource called gig The speaker outlines the creation of a model for a resource called gig, using Sequelize's define method to specify fields such as title, technologies, description, budget, and contact email.", "Moving the database configuration to a separate file The chapter demonstrates the organization of code by creating a separate file 'database.js' within a 'config' folder to contain the database configuration, and then exporting it for access in other files.", 'Setting up a database connection using Sequelize The speaker explains the process of connecting to a database using Sequelize, calling the authenticate method, and handling successful and error scenarios.']}, {'end': 1445.405, 'segs': [{'end': 1129.555, 'src': 'embed', 'start': 1066.03, 'weight': 0, 'content': [{'end': 1070.092, 'text': "Then we're going to have a separate file for all the routes that have to do with gigs.", 'start': 1066.03, 'duration': 4.062}, {'end': 1080.037, 'text': "So fetch fetching them, you know, the the the post or I'm sorry, the the search adding them, things like that.", 'start': 1070.212, 'duration': 9.825}, {'end': 1084.6, 'text': "So let's create another folder in our route here called routes.", 'start': 1080.257, 'duration': 4.343}, {'end': 1090.917, 'text': "OK And inside there we're going to have a file called gigs dot J.S.", 'start': 1085.572, 'duration': 5.345}, {'end': 1094.18, 'text': 'OK So this is going to be all the routes for our gigs.', 'start': 1091.978, 'duration': 2.202}, {'end': 1095.862, 'text': 'Now we have to point to this file.', 'start': 1094.24, 'duration': 1.622}, {'end': 1098.364, 'text': "So I'm going to go back to app J.S.", 'start': 1096.502, 'duration': 1.862}, {'end': 1102.688, 'text': 'and down here at the bottom right above the port.', 'start': 1098.704, 'duration': 3.984}, {'end': 1106.651, 'text': "Let's say gig routes.", 'start': 1102.848, 'duration': 3.803}, {'end': 1124.351, 'text': "So we're going to create I'm going to say app.use and for anything that's slash gigs, we want to require the gigs route.", 'start': 1108.033, 'duration': 16.318}, {'end': 1129.555, 'text': "So it's going to be dot slash routes slash gigs.", 'start': 1124.411, 'duration': 5.144}], 'summary': 'Creating separate file for gigs routes in app.js', 'duration': 63.525, 'max_score': 1066.03, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM01066030.jpg'}, {'end': 1250.482, 'src': 'embed', 'start': 1225.017, 'weight': 2, 'content': [{'end': 1232.701, 'text': "Now, what I want to do in this route is I want to be able to fetch all the gigs that are in the database, which right now we don't have any.", 'start': 1225.017, 'duration': 7.684}, {'end': 1236.523, 'text': 'But I still want to add the functionality for that.', 'start': 1233.762, 'duration': 2.761}, {'end': 1241.966, 'text': "And then we'll start to work on adding the form so that we can actually add gigs and stuff like that.", 'start': 1236.623, 'duration': 5.343}, {'end': 1250.482, 'text': "Um, you can go into PG admin or PHP, my admin, whatever, or the terminal, and you can add data that way, but I'm not going to bother doing that.", 'start': 1242.877, 'duration': 7.605}], 'summary': 'Developing functionality to fetch and add gigs to database.', 'duration': 25.465, 'max_score': 1225.017, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM01225017.jpg'}, {'end': 1328.485, 'src': 'embed', 'start': 1268.533, 'weight': 3, 'content': [{'end': 1272.754, 'text': 'So we want to go outside of routes into config and then database.', 'start': 1268.533, 'duration': 4.221}, {'end': 1282.278, 'text': "And then instead of doing this res.send, I'm sorry, we need to bring in our model as well.", 'start': 1273.915, 'duration': 8.363}, {'end': 1284.399, 'text': "So let's say const, I'm going to call it gig.", 'start': 1282.358, 'duration': 2.041}, {'end': 1288.551, 'text': "We're going to set this to require and then point to the model.", 'start': 1285.267, 'duration': 3.284}, {'end': 1298.221, 'text': "So outside of routes into models and then we want gig and instead of res dot send we'll get rid of that.", 'start': 1288.871, 'duration': 9.35}, {'end': 1305.75, 'text': "Let's say gig dot and then we can use any method that's available with sequel eyes such as find all.", 'start': 1298.362, 'duration': 7.388}, {'end': 1308.511, 'text': 'So we want to use findAll.', 'start': 1307.25, 'duration': 1.261}, {'end': 1311.673, 'text': 'Now what this does is it returns a promise.', 'start': 1308.891, 'duration': 2.782}, {'end': 1315.056, 'text': "So I'm actually going to go on to the next line here.", 'start': 1312.374, 'duration': 2.682}, {'end': 1319.158, 'text': "And it returns a promise, so we're going to use a .then.", 'start': 1316.677, 'duration': 2.481}, {'end': 1328.485, 'text': "So we'll do .then and we'll do .catch in case there's some kind of error.", 'start': 1319.178, 'duration': 9.307}], 'summary': 'Configuring database to use sequelize for finding all gigs, returning a promise with .then and .catch.', 'duration': 59.952, 'max_score': 1268.533, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM01268533.jpg'}, {'end': 1444.064, 'src': 'embed', 'start': 1367.27, 'weight': 6, 'content': [{'end': 1372.619, 'text': "We'll just send a status of 200 just so it's not hanging.", 'start': 1367.27, 'duration': 5.349}, {'end': 1376.843, 'text': "All right, so let's try that and see what we get.", 'start': 1374.522, 'duration': 2.321}, {'end': 1383.926, 'text': "So if we go to slash gigs and reload, we get OK because we're just sending a 200 status.", 'start': 1377.163, 'duration': 6.763}, {'end': 1388.188, 'text': "But let's go back into VS code and take a look down here.", 'start': 1383.946, 'duration': 4.242}, {'end': 1397.572, 'text': "So what we get is an empty array, and that's exactly what we expect because we don't have any data in there, but it shows us the query.", 'start': 1389.389, 'duration': 8.183}, {'end': 1401.294, 'text': 'So select ID title technologies, all of our fields.', 'start': 1397.672, 'duration': 3.622}, {'end': 1404.516, 'text': "It's selecting from gigs as gig.", 'start': 1401.954, 'duration': 2.562}, {'end': 1411.061, 'text': "So even though we don't have any data, everything looks OK and it should be working.", 'start': 1405.477, 'duration': 5.584}, {'end': 1419.807, 'text': "And if you like I said, if you want to add data through PG admin or my PHP, my admin, if you're using my SQL, you can do that.", 'start': 1412.341, 'duration': 7.466}, {'end': 1426.632, 'text': "But I think that I'm going to stop the video here now that we have our database set up, we are connected to it.", 'start': 1420.347, 'duration': 6.285}, {'end': 1430.534, 'text': "We're able to query it using our model that we created.", 'start': 1427.032, 'duration': 3.502}, {'end': 1437.939, 'text': "So, in the next video we're going to start to implement our template engine, which is handlebars, so that we can,", 'start': 1430.995, 'duration': 6.944}, {'end': 1443.343, 'text': 'we can have an interface to work with and we want to be able to add gigs through a form.', 'start': 1437.939, 'duration': 5.404}, {'end': 1444.064, 'text': 'All right.', 'start': 1443.363, 'duration': 0.701}], 'summary': 'Successfully set up database, able to query using model. next, implementing handlebars template engine for interface and form input.', 'duration': 76.794, 'max_score': 1367.27, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM01367270.jpg'}], 'start': 1029.272, 'title': 'Setting up web routes and database in node.js', 'summary': 'Covers setting up routes for a web application, creating separate files for different routes, configuring sequelize in node.js, querying data, and preparing for implementing a template engine, with a focus on using handlebars for creating an interface and adding gigs through a form.', 'chapters': [{'end': 1268.513, 'start': 1029.272, 'title': 'Setting up routes for gigs', 'summary': 'Covers setting up routes for a web application, including creating separate files for different routes, pointing to the file in the main app.js, and creating a route to fetch all gigs from the database.', 'duration': 239.241, 'highlights': ['Creating separate file for gigs routes The chapter discusses creating a separate file called gigs.js to contain all the routes for gigs, ensuring modularity and organization.', "Pointing to gigs route in app.js The process of pointing to the gigs route file in app.js using app.use('/gigs', require('./routes/gigs')) is explained, ensuring that any requests to '/gigs' are directed to the gigs route.", 'Creating route to fetch all gigs from database The author outlines the creation of a route to fetch all gigs from the database, highlighting the importance of this functionality for future development.']}, {'end': 1328.485, 'start': 1268.533, 'title': 'Configuring sequelize in node.js', 'summary': 'Explains how to configure sequelize in a node.js application, including bringing in models, using sequelize methods like findall, and handling promises with .then and .catch.', 'duration': 59.952, 'highlights': ['Bringing in models by requiring the model and using it to perform operations like find all', 'Using Sequelize methods like findAll to retrieve data, which returns a promise', 'Handling promises with .then and .catch to manage successful and error responses']}, {'end': 1445.405, 'start': 1329.446, 'title': 'Setting up database and querying data', 'summary': 'Covers setting up a database, querying data, and preparing for implementing a template engine, with a focus on using handlebars for creating an interface and adding gigs through a form.', 'duration': 115.959, 'highlights': ['The chapter focuses on setting up a database and connecting to it, demonstrating the ability to query data using a created model.', 'Implementing a template engine, specifically handlebars, to create an interface for adding gigs through a form, is highlighted as the next step in the process.', 'The process of querying data is demonstrated through console.log and res.send, with emphasis on sending a status of 200 to avoid hanging.', 'The transcript provides insights into the structure of the database query, including the fields being selected and the table being queried, even when there is no data available.', 'The chapter concludes with a plan to implement a template engine, handlebars, for creating an interface and adding gigs through a form.']}], 'duration': 416.133, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/bOHysWYMZM0/pics/bOHysWYMZM01029271.jpg', 'highlights': ['Creating separate file for gigs routes The chapter discusses creating a separate file called gigs.js to contain all the routes for gigs, ensuring modularity and organization.', "Pointing to gigs route in app.js The process of pointing to the gigs route file in app.js using app.use('/gigs', require('./routes/gigs')) is explained, ensuring that any requests to '/gigs' are directed to the gigs route.", 'Creating route to fetch all gigs from database The author outlines the creation of a route to fetch all gigs from the database, highlighting the importance of this functionality for future development.', 'Bringing in models by requiring the model and using it to perform operations like find all', 'Using Sequelize methods like findAll to retrieve data, which returns a promise', 'Handling promises with .then and .catch to manage successful and error responses', 'The chapter focuses on setting up a database and connecting to it, demonstrating the ability to query data using a created model.', 'Implementing a template engine, specifically handlebars, to create an interface for adding gigs through a form, is highlighted as the next step in the process.', 'The process of querying data is demonstrated through console.log and res.send, with emphasis on sending a status of 200 to avoid hanging.', 'The transcript provides insights into the structure of the database query, including the fields being selected and the table being queried, even when there is no data available.', 'The chapter concludes with a plan to implement a template engine, handlebars, for creating an interface and adding gigs through a form.']}], 'highlights': ['The chapter details the process of creating a database table for gigs, specifying the column names, data types, and lengths for each field, including details for primary and foreign keys, with a focus on using Postgres and MySQL.', "The chapter demonstrates creating a database named 'code gig' using PG admin and Postgres user.", "The chapter emphasizes the importance of creating a table within the 'code gig' database to store gig details.", 'The chapter focuses on building an application using Node.js Express and SQLize with an emphasis on using Postgres as the database.', 'Covers the setup of a Node.js server, installation of Postgres, PG and PG-Hstore, and the addition of dev dependency nodemon for automatic server refresh.', 'Setting up a connection with Sequelize involves creating a variable and setting it to new Sequelize, passing the necessary database connection details, such as database name, username, password, host, and dialect.', 'Creating separate file for gigs routes The chapter discusses creating a separate file called gigs.js to contain all the routes for gigs, ensuring modularity and organization.', "Pointing to gigs route in app.js The process of pointing to the gigs route file in app.js using app.use('/gigs', require('./routes/gigs')) is explained, ensuring that any requests to '/gigs' are directed to the gigs route.", 'Creating a route to fetch all gigs from database The author outlines the creation of a route to fetch all gigs from the database, highlighting the importance of this functionality for future development.']}