/week-10

[express, mean, mongo, mongoose, mvc, auth, oauth]

Week 10

Mongoose

Question #1

Describe the differences between a SQL and NoSQL DB, and when you might use each.

Your answer...

Question #2

What's wrong with this mongoose code and how might we fix it? (Hint: Assuming there is a document with a name of "Bob", why is results not an author model on the second line?)

var results = AuthorModel.find({name: "Bob"});
console.log(results);
// Your answer...

Question #3

Convert the following ActiveRecord sequence to Mongoose:

@andy = Instructor.find_by(name: "Andy")
@andy.wishlist_items.create(description: "Resin Laying Deer Figurine, Gold")
// Your answer...

Question #4

Convert the following create method in Mongoose to ActiveRecord.

  var authors = {
  create: function(req, res){
  var author = new AuthorModel({name: req.body.name})
  author.save(function(err){
    if (!err){
      res.redirect("authors")
    }
  })
  }  
}

Express

Question #5

How does module.exports help us with separation of concerns?


Question #6

Write one Express route for each of the four HTTP methods.

Then, make each route respond with a one-word string containing the RESTful action that would most likely be associated with this route.

var express = require("express");
var app = express();

// Your code starts here...
// Your answer...

Question #7

Describe the differences between Express and Rails as backend frameworks.


Question #8

What is the importance of using body-parser in our express application for post requests?