Create a commandline todo list app that you can use from your terminal and that will keep track of things you need to do.
node todo.js show
1. [ ] - go shopping
2. [ ] - feed dog
3. [ ] - swim practice
4. [ ] - code app
5. [ ] - meet gabriel
node todo.js add "eat bak kut teh"
1. [ ] - go shopping
2. [ ] - feed dog
3. [ ] - swim practice
4. [ ] - code app
5. [ ] - meet gabriel
6. [ ] - eat bak kut teh
Create and install some things:
npm init
npm install pg
Create the database itself.
First, drop into psql
:
Create the DB:
CREATE DATABASE todo
Create a tables.sql file:
CREATE TABLE IF NOT EXISTS items (
id SERIAL PRIMARY KEY,
name text
);
(you can create a seed.sql file if you want).
Run tables.sql
psql -d todo -U USERNAME -f tables.sql
Now you can start coding the index.js
file. The one provided has some boilerplate code for you to start.
node todo.js done 4
1. [ ] - go shopping
2. [ ] - feed dog
3. [ ] - swim practice
4. [x] - code app
5. [ ] - meet gabriel
6. [ ] - eat bak kut teh
Add a column named created_at
with data type date and display the date the item was added.
Add the ability to permanently delete an item.
Add a column named updated_at
with data type date and display the date the item was marked completed.
Use an ascii art generator to add style to your app: http://patorjk.com/software/taag - here you could use the ES6 string interpolation syntax.
There are frameworks to make a completely dynamic command line app. Use a framework to make the app interactive: https://medium.freecodecamp.org/writing-command-line-applications-in-nodejs-2cf8327eee2