Bootcamp
Search…
3.POCE.4: SQL Meal Tracker

Base

Create a command line app that will keep track of meals that you've eaten.

Create Table

Write a CREATE TABLE statement based on information below and run it on your database.
column name
data type
description
example
id
SERIAL PRIMARY KEY
id
1
type
TEXT
The type of meal that was eaten.
breakfast, lunch, dinner
description
TEXT
Description of what was eaten.
McDonalds and KFC
amount_of___alcohol
INTEGER
Unit amount of alcohol consumed with meal.
3
was_hungry___before_eating
BOOLEAN
Was feeling hungry before eating or not.
true, false

Enter a Meal

Create functionality for the user to log a meal using the command line, where the meal gets saved to the DB.
Feel free to customise your edit command format. The format in the below command is:
node index.js log <TYPE> <DESCRIPTION> <AMOUNT_OF_ALCOHOL> <WAS_HUNGRY_BEFORE_EATING>
1
node index.js log breakfast 'nasi lemak' 0 true
Copied!

See Meals So Far

Create functionality for the user to see all of their past meals using the command line, where meals are read from the DB.
1
node index.js report
Copied!

Comfortable

Update

When the report prints out the user's meals, allow the user to edit a meal.

Report Command

1
node index.js report
Copied!

Sample Report Output

Feel free to customise your report output format.
1
1 breakfast - nasi lemak - no alcohol - feeling hungry
2
2 lunch - burrito - 1 unit of alcohol - feeling hungry
Copied!

Sample Edit Command

Feel free to customise your edit command format. The format in the below command is:
node index.js edit <MEAL_ID> <COLUMN_NAME> <COLUMN_VALUE>
1
node index.js edit 1 type supper
Copied!

Report

Allow the user to make more fine-grained reports, for example only reporting meals with specific attributes.
1
node index.js report breakfast
Copied!
1
node index.js report hungry
Copied!
1
node index.js report not-hungry
Copied!

More Comfortable

created_at

Look up the Postgres Date type in the docs. Change the table to add another column called created_at.

Reports

Add some more detailed reports.
1
node index.js report drink
Copied!
Give statistics on how often (as a ratio) the user consumes alcohol at meal time.
Give statistics on what the average amount of alcohol per meal is.
Do these calculations in JavaScript.
Using the created_at column, get a list of all meals since the week began.
1
node index.js report week-so-far
Copied!
Using the created_at column, get a list of the meals in the past seven days not including today.
1
node index.js report past-week
Copied!

Deploy

Deploy the app into a new instance of EC2. (You will have to install Postgres on the instance). Use your meal tracker remotely via SSH from your local computer.

Access App via SSH on Mobile

Download an iPhone or Android app to access your meal tracker via SSH on mobile.

Reference Solution

Click here to see the reference solution for this post class.