Relational Database
For this lab you will:
queries.md
file under the appropriate heading.accounts
resource, including database logicVisit SQL Try Editor at W3Schools.com using the Google Chrome (or Chromium if you use Linux) browser and write SQL queries for the following requirements:
Clicking the Restore Database
button in the page will repopulate the database with the original data and discard all changes you have made.
accounts
resource. Use the db
object imported from data/dbConfig.js
for database access via knex
.Insomnia
or Postman
to check they are working as expected.field | data type | metadata |
---|---|---|
id | unsigned integer | primary key, auto-increments, generated by database |
name | string | required, unique |
budget | numeric | required |
The following exercises require research, the concepts needed to complete them have not been covered in class yet.
query string
option to your GET /api/accounts
endpoint. The query string
may contain limit
, sortby
and sortdir
keys. If these keys are provided, use these values to limit and sort the accounts
which are selected from the database. Reference the docs for sorting and limiting in knex
.
// sample req.query object
{
limit: 5,
sortby: 'id',
sortdir: 'desc'
}