Skip to content

Instantly share code, notes, and snippets.

@niamurrell
Last active July 23, 2017 19:51
Show Gist options
  • Save niamurrell/eb80dff74e6af2d93a2283f275a267bc to your computer and use it in GitHub Desktop.
Save niamurrell/eb80dff74e6af2d93a2283f275a267bc to your computer and use it in GitHub Desktop.
RESTful Routing with DB Methods
Name URL Request Type Description MongoDB Method Sequelize Method
INDEX /posts GET Display list of all posts Post.find() Post.findAll()
NEW /posts/new GET Display form to make new post n/a n/a
CREATE /posts POST Add new post to database Post.create() Post.create()
SHOW /posts/:id GET Show info about specific post Post.findById() Post.findById()
EDIT /posts/:id/edit GET Show edit form for specific post Post.findById() Post.findById()
UPDATE /posts/:id PUT Update specific post & reroute to edited post Post.findByIdAndUpdate() Post.update()
DESTROY /posts:id DELETE Delete specific post & reroute Post.findByIdAndRemove() Post.destroy()

created by @niamurrell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment