Skip to content

mjhea0/learn-to-express-crud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How To Build an Express CRUD App

Specifically a blog using Jade and Mongoose. In this lesson you will learn

  • What is Express
  • How to create routes
  • What is Jade
  • How to render Jade templates
  • What is Mongo
  • What is Mongoose
  • How to create, read, update and delete with Mongoose models
  • How to utilize HTTP (via Express) to create, read, update and delete

Wow! That's sweet! 🆒

Step 1

Download the express-generator package from npmjs.org

npm install --global express-generator

Use the now globally installed CLI to genereate a new project called "blog"

express blog

Change directories to the blog project folder

cd blog

Install the projects dependencies from npmjs.org

npm install

Step 2

Change the homepage to have the title of your blog.

  • Pass a new title to the Jade file

view code

Step 3

Cool site but could use some content. Let's setup a database.

Add mongoose as a dependency and save it to your package.json

npm install --save mongoose
  • Tell mongoose to connect to the mongo database

view code

  • create a new folder for your models
mkdir models
  • create models/post.js using the Mongoose API

view code

Step 4

A good nights REST

GET POST PUT DELETE
/posts/ Show all posts Add new post N/A N/A
/posts/<id> Show <id> N/A Update <id> Delete <id>

view code

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published