- 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:
id: primary key, auto-increments.name: text, required.
id: primary key, auto-increments.name: text, required.cohort_id: references theidin the cohorts table.
Use knex seeding feature to add test data to your tables.
Implement the following endpoints:
[POST] /api/cohortsThis route should save a new cohort to the database.[GET] /api/cohortsThis route will return an array of all cohorts.[GET] /api/cohorts/:idThis route will return the cohort with the matchingid.[GET] /api/cohorts/:id/studentsreturns all students for the cohort with the specifiedid.[PUT] /api/cohorts/:idThis route will update the cohort with the matchingidusing information sent in the body of the request.[DELETE] /api/cohorts/:idThis route should delete the specified cohort.
Add the following endpoints.
[POST] /studentsThis route should save a new student to the database.[GET] /studentsThis route will return an array of all students.[GET] /students/:idThis route will return the student with the matchingid.[PUT] /students/:idThis route will update the student with the matchingidusing information sent in the body of the request.[DELETE] /students/:idThis 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'
}