Code Monkey home page Code Monkey logo

practice-for-week-11-combining-express-sequelize-long-practice-2's Introduction

Long Practice: Using Sequelize In Express Routes

In this long practice, you will be using Sequelize in an Express server to run migrations, seed the database, and connect GET, PUT, DELETE and UPDATE routes to their appropriate database operations.

This project parallels one you completed in SQL. Hopefully through this process, you'll develop a better appreciation for the power of Sequelize to simplify database operations.

Getting started

Download the starter. cd into server folder, and install dependencies using npm install.

Create a server/.env file in order to store environment variables. Add a variable DB_FILE (which is already in use in server/config/database.js). You can model the .env file after .env.example, specifying the location of the database to be created.

Notice that the starter includes server/.sequelizerc and server/config/database.js, as well as migrations, models, and seeders in the server/db folder.

Migrations and seeders

Run the appropriate migrate command using the Sequelize CLI to create the database and the table(s) specified in the existing migrations.

Remember: You'll need dotenv before npx in order to set the environment variable for the database file location.

Verify that the db/dev.db file was created. If you encounter any errors or do not see this file, go back and check that your .env file has been accurately set up.

Verify the table exists by checking its schema using the Sqlite CLI.

Run the appropriate seed command using the Sequelize CLI.

Verify the table has data using the Sqlite CLI.

Run the application

Start the Express server in development mode using

npm run dev

In your browser or Postman, load the root path: http://localhost:5000/

If all is working correctly, you should see {"message":"API server is running"}.

Phases

This project has been broken down into phases. Complete as much as you can in the time allotted. You can complete any remaining phases for additional practice during assessment prep.

If you get stuck, try moving on to the next phase for now, then come back later in the project to complete or improve your code. Also, you can formulate good questions, and reach out to your instructors for help.

References

You may refer to your previous work, the Sequelize documentation, the documentation for Sequelize CLI, or online resources to assist you in completing this practice.

Good luck! You can do it!!!

practice-for-week-11-combining-express-sequelize-long-practice-2's People

Contributors

aa-assessment-project-manager[bot] avatar lloydakresi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.