Giter VIP home page Giter VIP logo

exercise_w05d05_mongo_node_express's Introduction

πŸ‹οΈ Working with Mongo in Node with Express

Let's practice issuing commands to our MongoDb server via HTTP!

πŸ‘· Setup

  • Fork and clone this repo.
  • Install your dependencies with npm install and start up your server.
  • Start up a mongoDB server!

πŸ”¬ Getting started

Start poking around.

Directory Structure

.
β”œβ”€β”€ README.md
β”œβ”€β”€ app.js
β”œβ”€β”€ package.json
β”œβ”€β”€ public
β”‚Β Β  β”œβ”€β”€ main.js
β”‚Β Β  └── style.css
β”œβ”€β”€ routes
β”‚Β Β  └── index.js
└── views
    β”œβ”€β”€ index.hbs
    └── layouts
        └── main.hbs

4 directories, 8 files

  • Look through routes/index.js to see how we're connecting to MongoDB
  • Check out views/layouts/main.hbs what scripts are being loaded on the client side?
  • This app will connect to a mongoDB called "TESTER"

🀰 Crud

  • Visit '/' and try adding data.
  • Connect to the MongoDB via the mongoshell to ensure data is making its way there!

Implement the following user stories

πŸ“– cRud

When a user visits '/'

  • they should see a button "Get Data"

When a user visits '/data'

  • The server should respond with JSON of all the inserted data

When a user visits '/' and clicks "Get Data" - the client should perform an XHR GET request to '/data' - the server should retrieve all the data from MongoDB - the server should return a JSON response of the data

When a user visits '/comments' - the server should retrieve all the data from MongoDB - the server should render an HTML response using a Handlebars template

update to readme

When a user visits '/data/[objectId]'

  • The server should respond with JSON of that inserted data with that objectId

When a user visits '/comments/[objectId]' - the server should retrieve that data from MongoDB - the server should render an HTML response using a Handlebars template

πŸ’€ cruD

Update the rendered list of data to include a "DELETE" button next to each item in the list

When a user clicks on "DELETE" for an item

  • the client should send an XHR POST request '/data/[objectId]/delete'
  • the server should remove the data with that objectId from the server
  • the server should return a JSON response of {status: 200}
  • the client should remove that item from the list

πŸ’… crUd

Update the rendered list of data to include a "UPDATE" button next to each item in the list

When a user clicks "UPDATE" for an item

  • the client should send an HTTP POST request to '/data/[objectId]'
  • the server should modify the data with that objectId and change the author to "Shakespeare"
  • the server should send back a JSON response of {status: 200}
  • the client should change the name in the list

πŸš€ Bonus

When a user visits "/" and clicks "GET DATA" - render the JSON response with a client side templating language - handlebars or ejs, check "main.hbs" for Handlebars or Underscore

When a user visits '/comments/[objectId]/edit' - the server should render an HTML response using a Handlebars template - the response should include an HTML form - the form fields should be pre-populated with the values from the data

When a user visits '/comments/[objectId]/edit' and changes the data and clicks "Update" - the client should send an HTTP POST request with the data to '/data/[objectId]' - the server should update the data with that objectId with the data from the body of the post request - the server should send back a 302 response and redirect the browser to '/'

Add a nav bar to the main.hbs layout template to provide links to 'Home' and 'Data'

πŸ€·β€β™€οΈResources

exercise_w05d05_mongo_node_express's People

Contributors

phlco avatar boshika avatar blizm87 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.