diff --git a/README.md b/README.md index 16ddfeb..3aaa29c 100644 --- a/README.md +++ b/README.md @@ -23,5 +23,4 @@ 1. Morning Lecture: [Nested Models](day3/instructor_notes/Nested_Models.md) 1. Morning Lab: Implement Find for Both `/people/:id` and `/locations/:id` with Nested Models 1. Afternoon Lab (no lecture): Implement a Many-to-Many Relationship with a `Companies` Model - - use a `jobs` intermediary table 1. Homework: Finish Lab diff --git a/day3/homework/README.md b/day3/homework/README.md new file mode 100644 index 0000000..c539ea0 --- /dev/null +++ b/day3/homework/README.md @@ -0,0 +1,3 @@ +# Homework + +Finish all labs from today and yesterday diff --git a/day3/student_labs/afternoon.md b/day3/student_labs/afternoon.md new file mode 100644 index 0000000..4d9ef15 --- /dev/null +++ b/day3/student_labs/afternoon.md @@ -0,0 +1,3 @@ +# Lab + +Implement a Many-to-Many Relationship with a `Companies` Model (see [yesterday's morning lab](../../day2/student_labs/morning.md) for details on how the model should be structured). Use a `jobs` intermediary table. diff --git a/day3/student_labs/morning.md b/day3/student_labs/morning.md new file mode 100644 index 0000000..d7cb330 --- /dev/null +++ b/day3/student_labs/morning.md @@ -0,0 +1,40 @@ +# Lab + +Implement a show route for our people model (`/people/:id`) which will return to the client JSON representing the requested row in the `people` table along with a nested `home` attribute which will be the selected person's related location: + +```JSON +{ + "id":4, + "name":"Bob", + "age":25, + "home": { + "id":2, + "street": "123 Fake Street", + "city": "Aurora", + "state": "NY" + } +} +``` + +Do the same for locations (`/locations/:id`), but include a nested `inhabitants` attribute, which will be an array, containing objects representing the rows in the `people` table related to the selected location: + +```JSON +{ + "id":2, + "street": "123 Fake Street", + "city": "Aurora", + "state": "NY", + "inhabitants":[ + { + "id":4, + "name":"Bob", + "age":25 + }, + { + "id":7, + "name":"Sally", + "age":74 + }, + ] +} +```