- Databases
- Relational Databases
- Knex migrations.
- Seeding data.
Build an API that persists data to SQLite3.
Use knex migrations to create a database called lambda.sqlite3
and add the following tables:
[ x ]
id
: primary key, auto-increments.name
: text, required.
[ x ]
id
: primary key, auto-increments.name
: text, required.cohort_id
: references theid
in the cohorts table.
Use knex seeding feature to add test data to your tables. [ x ]
Implement the following endpoints:
- [ x ]
[POST] /api/cohorts
This route should save a new cohort to the database. - [ x ]
[GET] /api/cohorts
This route will return an array of all cohorts. - [ x ]
[GET] /api/cohorts/:id
This route will return the cohort with the matchingid
. - [ x ]
[GET] /api/cohorts/:id/students
returns all students for the cohort with the specifiedid
. - [ x ]
[PUT] /api/cohorts/:id
This route will update the cohort with the matchingid
using information sent in the body of the request. - [ x ]
[DELETE] /api/cohorts/:id
This route should delete the specified cohort.
Add the following endpoints.
- [ x ]
[POST] /students
This route should save a new student to the database. - [ x ]
[GET] /students
This route will return an array of all students. - [ x ]
[GET] /students/:id
This route will return the student with the matchingid
. - [ x ]
[PUT] /students/:id
This route will update the student with the matchingid
using information sent in the body of the request. - [ x ]
[DELETE] /students/:id
This route should delete the specified student.
Have the student returned by the [GET] /students/:id
endpoint include the cohort name and remove the cohort_id
fields. The returned object should look like this:
{
id: 1,
name: 'Lambda Student',
cohort: 'Full Stack Web Infinity'
}