Git Product home page Git Product logo

pokedex-express-users's Introduction

Pokedex Express - Many-to-Many

Getting Started

  1. Fork and clone this repository to your computer
  2. Run npm install to install dependencies
  3. Create a new Postgres database by running createdb pokemons -U <your_username>
  4. Run psql -U <your_username> -d pokemons -a -f tables.sql to create a pokemon table in the database
  5. Look in the starter file called index.js, run nodemon to start local server on port 3000
  6. Open localhost:3000 on your browser and see the home page

Deliverables

The deliverable is an app that has CRUD functionality on pokemons that can be associated with users. Some example code from the previous version of the exercise has been provided for you to build on, although you may extend your own code from the previous exercise if you wish to do so.

  • Create the relevant tables.sql file to create the appropriate table for your database

  • seed your DB with the pokedex.sql file

  • Create the association where a user can catch a pokemon. Users can catch many pokemon, and pokemon can be caught by many users. (this is a many-to-many relationship that must use a join table).

    • start with the simplest implementation of this feature- simply create a form that has a field for each id for each column of the join table
    • then, on the show route of the user (/users/1) write a query that will allow you to:
      • show what pokemon a user has captured

Further

  • For a route showing a single user (/users/1). Add a form to this page that uses a select (drop down) to select a pokemon that was captured.

Further

On the show route of the pokemon, write a query that will allow you to:

  • show what users have captured that pokemon
  • add a form that will let users select a user that has captured that pokemon

Further

  • DELETE /pokemon/:id should delete the entry of the pokemon with the specified ID, and should redirect to the home page /

  • Create new routes for editing a user and deleting a user.

Further

If the user enters a pokemon to capture that has already been captured by the user, show an error.

Further

  • Add a types table and a pokemontypes table in your database, and create a seed.sql file inserting relevant data for these 2 tables. Note that a pokemon can have many types, and a type can have many pokemons.

Useful SQL commands

Note the proceeding commands should be run in a psql session on Terminal.

View all the data in a table:

SELECT * FROM pokemon;

Delete your database and start again if you made a mistake:

DROP DATABASE pokemons;

Or if you just need to reset the table:

DROP TABLE pokemons;

pokedex-express-users's People

Contributors

chloeliang avatar awongh avatar ckkok avatar

Watchers

James Cloos avatar  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.