Giter Club home page Giter Club logo

checkpoint-07's Introduction

Week 10

Mongoose

Question #1

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

SQL is a relational database structure. Meaning that it update and retrieve datas.
NoSQL is a non-relational database that store data in JSON documents and it contains key/value pairs.
SQL is good for structured data if the data that's inputed has the consistent properties. NoSQL is better used for more complex or nested data.

Question #2

What's wrong with this Mongoose code and how might we fix it?

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

Hint: Assuming there is a document with a name of "Bob", why does results not contain an author model on the second line?

var results = AuthorModel.find({name: "Bob"}, (err, authors) => {
  console.log(results)
})

You need callback.

Question #3

Convert the Ruby and ActiveRecord code below into Javascript and Mongoose code:

@andy = Instructor.find_by(name: "Andy")
@andy.wishlist_items.create(description: "Resin Laying Deer Figurine, Gold")
var andy = Instructor.findOne({name: "Andy"}, (err, instructor) => {
  console.log(andy)
})

var wish = new Wishlist_item(description: "Resin Laying Deer Figurine, Gold")

wish.save((err, wishlist_item) => {
  if(err){
    console.log(err)
  }else{
    console.log(wishlist_item)
  }
})

Question #4

Convert the following create method in Mongoose to ActiveRecord.

var author = new Author({name: req.body.name})
author.save(function(err){
  if (!err){
    res.redirect("authors")
  }
})
author = Author.create(name: => "author's name")

Express

Question #5

What is module.exports and why do we use it?

module.exports is one of require method that by assigning particular values to it, we can explicity define the object that will be brought in when another file requires() the file from which we are exporting.

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();

//GET
app.get('/', function(req, res) {
  res.send('Get')
})

//POST
app.post('/', function(req, res) {
  res.send('Post')
})

//PUT
app.put('/random', function(req, res) {
  res.send('Put')
})

//DELETE
app.delete('/random', function(req, res) {
  res.send('Delete')
})

Question #7

Describe the differences between Express and Rails as backend frameworks.

Expree is more open world to structure our application. Express is better for fast single page apps.

Rails goes through middleware to process and requires GEMS to process and respond to requests.

Question #8

What do the following lines of code do?

var bodyParser = require("body-parser")
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
Telling express to use body-parser and to look at all incoming data as a json object

If You Finish Early...

Take a look at these front end developer interview questions

checkpoint-07's People

Contributors

amaseda avatar beckybeauchamp1 avatar jshawl avatar kwonih1020 avatar robertakarobin avatar superbuggy 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.