GithubHelp home page GithubHelp logo

lackdaz / multi-model-todo-list Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wdi-sg/multi-model-todo-list

0.0 2.0 0.0 9 KB

Extending the Todo List Application to include multiple models

JavaScript 41.74% CSS 0.50% HTML 57.76%

multi-model-todo-list's Introduction

Multi Model Todo List

This is Part 5 of a series of labs working towards building your first full stack web app.

So far you've built a full MVC Todo List Application. This is a great achievement but it's time to take it up a notch. In this Lab you'll be extending your Application to support multiple Models.

Exercise

Your Task is to Add a TodoGroup Model. A TodoGroup should contain at minimum:

  • a Name
  • a Color (you can use this as your page background-color)
  • and include multiple Todos (accordingly each Todo belongs to a TodoGroup)

You'll need to decide whether to use Mongoose Embedding or Referencing for the Relationship. Spend 10 minutes discussing this with your Neighbors to review the benefits of each and pick the right method for the job.

Try to use Nested Routing like below.

  • GET /todogroups

  • POST /todogroups

  • GET /todogroups/new

  • GET /todogroups/:id

  • GET /todogroups/:id/edit

  • PUT /todogroups/:id/

  • DELETE /todogroups/:id/

  • GET /todogroups/:group_id/todos - List All the Todos that belong to the specified TodoGroup

  • POST /todogroups/:group_id/todos - Create a new Todo and link it to the specified TodoGroup

  • GET /todogroups/:group_id/todos/new - Render a form that allows a Todo to be added to the specified TodoGroup

  • GET /todogroups/:group_id/todos/:id - Render a page that shows the a specific Todo from the specified TodoGroup

  • GET /todogroups/:group_id/todos/:id/edit - Render a form that allows editing of a specific Todo from the specified TodoGroup

  • PUT /todogroups/:group_id/todos/:id/ - Update a specific Todo from the specified TodoGroup

  • DELETE /todogroups/:group_id/todos/:id/ - Delete a specific Todo from the specified TodoGroup

The above routes will give you two params in your request object req.group_id & req.id. Depending on your chosen Storage approach, you will need to use these differently.

Bonus:

  • Nested Routes can get quite clunky. Try to use shallow nested routes instead. This means that you only have the id for a TodoList in the url when it is need, in other cases you retrieve it from the child object itself. For example...

  • GET /todogroups/:group_id/todos - List All the Todos that belong to the specified TodoGroup

  • POST /todogroups/:group_id/todos - Create a new Todo and link it to the specified TodoGroup

  • GET /todogroups/:group_id/todos/new - Render a form that allows a Todo to be added to the specified TodoGroup

  • GET /todos/:id - Render a page that shows the a specific Todo (the id is unique, so we don't need the parent list)

  • GET /todos/:id/edit - Render a form that allows editing of a specific Todo

  • PUT /todos/:id/ - Update a specific Todo

  • DELETE /todos/:id/ - Delete a specific Todo

Bonus Bonuses

  • Allow a Todo to be reassigned it's parent TodoGroup from it's Edit Page
  • Make Sure that Deleting a TodoGroup also deletes all of it's children

multi-model-todo-list's People

Contributors

primaulia avatar jeremiahalex avatar terencelimsayjian avatar taykangsheng avatar nickangtc avatar

Watchers

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