924
Lectures Watched
Since January 1, 2014
Hundreds of free, self-paced university courses available:
my recommendations here
Peruse my collection of 275
influential people of the past.
View My Class Notes via:
Receive My Class Notes via E-Mail:

VIEW ARCHIVE


Contact Me via E-Mail:
edward [at] tanguay.info
Notes on video lecture:
MongoDB, node.js, Express and SWIG
Choose from these words to fill the blanks below:
routing, package, BSON, callback, two, npm, column
npm
package manager for node.js
node app.js
cannot find package
express = require('express') in app.js
so we have do npm install express
also requires express and mongodb
we could install these indivually or with               .json
we just have to say        install
installs them in node_modules directory
you could also install them globally
helloworld in mongodb
node.js driver
communicates with mongod with         , a binary jSON
driver is written in javascript
handles things behind the scenes
how to install
node app.js
cannot find module mongodb
installs mongodb module
var mc = require('mongodb').MongoClient;
access the driver
pass in a callback, it calls it when done connecting
helloworld in express
takes care of                and details of web application for us
callback takes two arguments
app.get has respond and request in callback
express server started on port 8080
in app.get, the star is wildcard for any handler that is not handled
extending helloworld in express
make file views/hello.html
<h1>Hello, {name}</h1>
templating engine: consolidate
a set of wrappers for template libraries for express
app.engine('html',cons.swig);
cons is consolidate and swig is the templating engine
helloworld with mongodb, express, and swig
adding calls to mongo db from the last example
Server = require('mongodb').Server;
told it to use the native BSON parser
not registering a callback
it looks like we are using our database connection before it is even connected
but we actually start listening as soon as the database connection is open
we are just setting up mongoClient as an object and then pass it as a parameter in the                 
express: handling GET requests
registering only one route
app.get('/:name', ...
uses this template
express: handling POST requests
form to pick radio button choice
we have app.get and app.post
express.bodyParser() populates req.body so we can access it
error handling function
call next with an error object
mongodb is schemaless
in RDBMS if you want to add a new field to a row, you need to create a new              for all rows in the table
you don't need to do this in mongodb
this allows mongodb to be very agile
JSON
there are only        data structures inside JSON
arrays
[...]
dictionaries
{ key : value, key : value }
blog project
database model if we used RDBMS
database model in mongodb
you can embed the comments in the posts
if the email is missing from any comment, it doesn't matter, you can leave it out
it is the way you access the data that guides how to design your data structures
MongoDB Introduction
Installing MongoDB/node.js and Hello Worlds
MongoDB, node.js, Express and SWIG
Basic Querying in MongoDB
More Querying in MongoDB
MongoDB CRUD via Node.js
Comparing RDBMS and MongoDB Schema Design