M101JS: MongoDB for Node.js Developers (Week 1: Introduction)

I am going to be documenting my progress through the MongoDB University course. It is just an introduction to MongoDB, but I am still so very new at working with Mongo that it can’t hurt to have the extra practice.  And at the end of the course I should have created a few more applications! Here goes…

Welcome to M101JS

  • Course grade is made up of 50% homework assignments, and 50% final project.

What is MongoDB?

  • Simple explanation about the document model and scalability benefits of using mongodb

Overview of Building an App with MongoDB

  • Clients make requests to the node server and the server uses a driver to make requests to the database. Still very simple..

JSON and BSON

  • JSON (javascript object notation) supports:
    • string, number, boolean, array, objects
  • standard key, value pairs
  • BSON is the binary translation of the JSON that mongo uses for storage

Intro to Creating and Reading Documents

  • I am noticing that the instructor uses ‘document’ and ‘object’ interchangably
  • using mongo does not return an object or an array of objects. Instead, it is a cursor object with a few methods of its own:
    • .next() allows you to cycle through the returned objects
    • .hasNext() returns a boolean depending on whether there are more documents in the cursor object

Hello World on Node.js

  • Just a demonstration of creating a simple server with nodejs

Intro to the Node.js Driver

  • require(‘mongodb’) and establishing a connection with the database
  • this section also discusses asynchronous callbacks

Hello World using Express

  • introduces the basic structure of an express server, which I am already familiar with through freeCodeCamp instruction.
  • For that matter, all of the mongo information thus far has already been covered in various assignments I have done through FCC.

Hello World using Templates

  • Discusses the concept of template libraries. ‘nunjucks’ is the engine used in this example.

Express: Handling GET Requests & Express: Handling POST Requests

  • How to extract GET and POST variables from a request
  • Using the body parser for post variables (req.body) and get parameters (req.params)

Homework

  • The homework for this first week was just 3 simple exercises. Each involved using ‘mongorestore’ and ‘npm install’ to find an answer key. Very simple

Challenge Problem: Create Movie Entries

  • Write a Node.js web application that presents users with a form containing three fields and a submit button. The fields should be:
    • title, year, imdb

Aaaaaaaaand, that is it for week 1! Great start. Having done a lot of this with FCC helped significantly, but there were still some new concepts. I had never used ‘mongorestore’ and it is very helpful to know how to import a new db.