Code Monkey home page Code Monkey logo

cli-todo-sql's Introduction

cli-todo-sql

https://i.giphy.com/media/26ufnwz3wDUli7GU0/giphy.webp

Create a commandline todo list app that you can use from your terminal and that will keep track of things you need to do.

Deliverables:

See the list

node todo.js show
1. [ ] - go shopping
2. [ ] - feed dog
3. [ ] - swim practice
4. [ ] - code app
5. [ ] - meet gabriel

Add to the list

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

Getting Started:

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 table:

CREATE TABLE IF NOT EXISTS items (
  id SERIAL PRIMARY KEY,
  name text
);

Now you can start coding the index.js file. The one provided has some boilerplate code for you to start.

Further:

Mark as done

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

Note that you may need to change your table to allow for "completion" of an item.

Further:

Add a column named created_at with data type date and display the date the item was added. Look ahead in the gitbook for how to format the date type with pg library https://wdi-sg.github.io/gitbook-2019/04-databases/postgres/sql-working.html

Further:

Add the ability to archive an item. When you archive an item it means it will no longer show in the list.

Further:

Add a column named updated_at with data type date and display the date the item was marked completed.

Further:

node todo.js stats complete-time give the average completion time of all items

Further:

In order to have data in your system for items that have been created and completed, write a separate file that inserts data into your database so that you can test that functionality.

Call it test.js. Inside create todo items and insert them into the database with the dates that will allow you to test your functionality.

Further:

node todo.js stats add-time give the average amount of items added per day.

Further:

node todo.js stats best-worst gives the item that was completed the fastest and the item that was completed the slowest.

Further:

node todo.js between 1/2/20 1/3/20 gives all the items added between these dates

Further:

Add the same as above but for items completed.

Further:

Get all the items completed between two dates and sort them by the time it took to complete. You can say ascending or descending order.

Ex. node todo.js stats between 1/2/20 1/3/20 complete-time asc

Further:

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.

Further:

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

Notes:

If you are working with dates, try the momentjs npm library.

cli-todo-sql's People

Contributors

awongh avatar samtanfl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.