Skip to content

Commit

Permalink
updates instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
luishrd committed Sep 5, 2018
1 parent 666df97 commit 87502c0
Showing 1 changed file with 29 additions and 38 deletions.
67 changes: 29 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,50 @@

Build an API that persists data to SQLite3.

Create the following database tables:
Use knex migrations to create a database called `lambda.sqlite3` and add the following tables:

Users
cohorts

- `id`: primary key, autoincrements.
- `name`: up to 128 characters long, required.
- `name`: text, required.
- `created_at`: defaults to the current date and time.

Posts
students

- `id`: primary key, autoincrements.
- `user_id`: references the id in the users table.
- `text`: no size limit, required.
- `name`: text, required.
- `cohort_id`: references the id in the cohorts table.
- `created_at`: defaults to the current date and time.

Tags

- `id`: primary key, autoincrements
- `tag`: string up to 16 characters long, unique.
- `created_at`: defaults to the current date and time.

Establish a many to many relationship between `Posts` and `Tags`. The same `tag` can be added to different `posts` and a `post` can have multiple `tags`. Add any tables necessary to accomplish this.

Add test data to your tables.
Use knex seeding feature to add test data to your tables.

Implement the following endpoints:

### Users
### Cohorts

- [POST] `/users` This route should save a new user to the database.
- [GET] `/users` This route will return an array of all users.
- [GET] `/users/:id` This route will return the user with the matching `id`.
- [GET] `/users/:id/posts` returns all posts for the user with the specified `id`.
- [PUT] `/users/:id` This route will update the user with the matching `id` using information sent in the body of the request.
- [DELETE] `/users/:id` This route should delete the specified user.
- `[POST] /api/cohorts` This route should save a new cohort to the database.
- `[GET] /api/cohorts` This route will return an array of all cohorts.
- `[GET] /api/cohorts/:id` This route will return the cohort with the matching `id`.
- `[GET] /api/cohorts/:id/students` returns all students for the cohort with the specified `id`.
- `[PUT] /api/cohorts/:id` This route will update the cohort with the matching `id` using information sent in the body of the request.
- `[DELETE] /api/cohorts/:id` This route should delete the specified cohort.

### Posts
### Students

- [POST] `/posts` This route should save a new post to the database.
- [GET] `/posts` This route will return an array of all posts.
- [GET] `/posts/:id` This route will return the post with the matching `id`.
- [PUT] `/posts/:id` This route will update the post with the matching `id` using information sent in the body of the request.
- [DELETE] `/posts/:id` This route should delete the specified post.

### Tags

- [POST] `/tags` This route should save a new tag to the database.
- [GET] `/tags` This route will return an array of all tags
- [GET] `/tags/:id` This route will return the tag with the matching `id`.
- [PUT] `/tags/:id` This route will update the tag with the matching `id` using information sent in the body of the request.
- [DELETE] `/tags/:id` This route should delete the specified tag.
- `[POST] /students` This route should save a new student to the database.
- `[GET] /students` This route will return an array of all students.
- `[GET] /students/:id` This route will return the student with the matching `id`.
- `[PUT] /students/:id` This route will update the student with the matching `id` using information sent in the body of the request.
- `[DELETE] /students/:id` This route should delete the specified student.

## Extra Credit

- add a [GET] `/posts/:id/tags` endpoint that returns all tags for the post with the specified `id`.
- have the post returned by the [GET] `/posts/:id` endpoint include the user name(not the id) and the tags associated with the post.
- have the student returned by the `[GET] /students/:id` endpoint include the cohort name and remove the `cohort_id` and `created_at` fields. The returned object should look like this:

```js
{
id: 1,
name: 'Lambda Student',
cohort: 'Full Stack Web Infinity'
}
```

0 comments on commit 87502c0

Please sign in to comment.