Git Product home page Git Product logo

u3_hw_sequelize_practice's Introduction

Sequelize Practice

Deliverables

You'll be creating a database with a theme of your choosing. You must have the following:

  • At least 3 models
  • Table names must be lowercased and snake_cased
  • CRUD queries for each model
    • C reate
    • R ead
    • U pdate
    • D elete

You can hard code in information for the create, update, and delete. You can either create 3 separate files or one file for all of these queries.

Getting Started

These commands should be done in order. Remember, if you are a Windows user, these commands will be different obviously.

npm init -y
npm install sequelize pg
sequelize init

Modify your config.json so that you're creating a database with your chosen name and modify the dialect to postgres.

Create your database:

sequelize db:create

Creating Models

To create a new model, run:

sequelize model:generate --name <Your Model Name Goes Here> --attributes <someattribute>:<somedatatype>,<other stuff...>

Remember, there can be no spaces in between each attribute.

Once your model is created, don't forget to add the tableName field in the model and adjust the migration generated accordingly.

After each model creation, run:

sequelize db:migrate

Generating Seeds

You can generate a seed file using:

sequelize seed:generate --name <Seed Name>

Run your seed using:

sequelize db:seed:all

Hint: You can also use falso:

npm i @ngneat/falso

Requiring Models

Don't forget to require your models in the file you're using for your queries:

const {} = require('./models')

Made A Mistake?

You can always revert a migration using:

sequelize db:migrate:undo

Submission

Submit your pull request utilizing the PR Guidelines.

u3_hw_sequelize_practice's People

Contributors

nobodyslackey avatar ahonore42 avatar anpato avatar ben-manning avatar

Watchers

Nabila Ayaba (she/her) 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.