I’m trying something new today. This is a project similar, but distinct from the afternoon project. The goal is to cover much of the same ground, but in a way that allows this to remain up for future cohorts to enjoy.
You can connect to a local sqlite database on the command line by running the
command sqlite3 dbName.sqlite3
. Navigate into the /data
directory and open
the dev.sqlite3
database this way. You can now run SQL queries against it.
(Don’t forget to end your commands with a ;
).
You can exit by pressing CTRL-d
. View the tables and their schema with the
commands .tables
and .schema tableName
.
Write CRUD endpoints for the reviews resource. Ideally, separate out your database interactions into a ‘model’ file and import that into your ‘router’ file.
field | data type | metadata |
id | unsigned int | primary key, auto |
rating | floating point number | 1-5, required |
book_id | unsigned int | foreign key, 1-15, required |
user_id | unsigned int | foreign key, 1-6, required |
comment | string | not required |
Handle query parameters to the GET /api/reviews
endpoint that may contain
limit
, sortby
and sortdir
.