Autoplay

Learn How To Develop a Landing Page and Collect Sales Leads using ExpressJS/NodeJS

30 high quality and free videos that teach ExpressJS, NodeJS, PostgreSQL, Bootstrap

Your First Controller

Learn what a controller is in the Model-View-Controller (MVC) pattern and develop the first one in your NodeJS App

Your first git commit

Learn what git and version control is, and make your first git commit.

Installing Nodemon

Learn how to install nodemon for your ExpressJS application. 

Create your first form on your landing page

Learn to create your first form.

Implement your first POST route

Learn how to implement an ExpressJS route doing a POST http request.

Install Postgres and Sequelize

Learn to install an SQL database on your Mac OS X

Create your first model and migration

Learn how to create your first database model using Sequelize ORM and a migration

Show a collection of leads

Learn how to show a collection of leads in a page

Implement show lead page

Learn how to display an individual sales lead

Implement edit, update lead routes

Learn how to implement edit/update leads

Implement delete lead route

Learn how to delete leads from the database.

Learn how to divide pug view files into reusable sections

Learn how to divide pug files into reusable mixins, create navbar, footer, head sections

Learn how to update landing page looks, and implement a navbar

Use bootstrap classes and html elements to make the landing page look better, add a navigation bar.

Learn how to implement user sign up and login using PassportJS - Part 1

Set up PassportJS and User model infrastructure for implementing login/signup routes.

Learn how to implement user login and sign up using PassportJS - 2

Implement login and sign up routes using everything set up in part 1.

Learn how to implement form validation and re-rendering forms with errors

Learn the simplest way to implement form validation in ExpressJS and the form re-render pattern.

Develop your first middleware in ExpressJS, and implement access control

Learn what a middleware is and implement page access control using middleware.

Create your first model and migration

Learn how to create your first database model using Sequelize ORM and a migration

Bahadir Balban

Buzz Founder

@learningexpressjs

Your first migration

Filename: 201901041917-CreateLeadTable.js

'use strict';
module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Leads', {
      id: {
        allowNull: false,
        primaryKey: true,
        type: Sequelize.UUID,
        defaultValue: Sequelize.UUIDV4,
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      email: {
      	allowNull: false,
      	type: Sequelize.STRING
      },
    })
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Leads');
  }
};

Your first model

Filename: Lead.js

/* jshint indent: 2 */
'use strict';
module.exports = (sequelize, DataTypes) => {
  var Lead = sequelize.define('Lead', {
    id: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      
      allowNull: false,
      primaryKey: true
    },
    email: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  });
  return Lead;
};


You Might Also Like...


Join The Discussion

Mike Gran

@mike38588

Sep 20

what is the purpose of this code: return models.sequelize.sync().then(result =>{})? I altered my model and when i initialize the web app this code calls a create table statement defined with columns I removed from my model. I can't figure out how to remove the old columns. Does that make sense?

Manjonka Diokou

@manjonka

Apr 23

I've created my first model but only get the following error whenever I try to save an email address (Error: SequelizeValidationError: notNull Violation: Lead.id cannot be null). I've judiciously followed your tutorial, so I'm not sure what's the problem. Thanks for any suggestion.