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:
Installing MongoDB/node.js and Hello Worlds
Choose from these words to fill the blanks below:
large, IO, 64, xvf, javascript, 27017, asynchronous, synchronous, callback, even, blocks
installing MongoDB on Mac
mongodb.org/downloads
always use     -bit versions
32-bit are only suitable for development
they limit total amount of data to 4 GB
stable releases are always         , e.g. 2.6.0
terminal window
tar        mongodb-osx-x86_64-2.6.0.tgz
cd into it
bin where the action is
mongo is shell to connect database
mongod runs the server
sudo bash
mkdir -p /data/db
chmod 777 /data/db
not good for production of course
start mongo server
./mongod
starts up
listening on port            (default)
start mongo shell
./mongo
test
db.names.insert({'name':'Joe'})
db.names.find()
installing on Windows
mongodb.org/downloads
always 64-bit if you can
find out:
powershell
wmic os get osarchitecture
130 MB
in Program Files
server:
mongod.exe
\data\db does not exist
create directories
client
new window
mongo.exe
db.names.insert({'name':'Joe'})
db.names.find()
introduction to Mongo shell
show dbs
use demo (creates it since it doesn't exist)
db.things.insert({'a':1, 'b': 2, 'c': 3})
db.things.insert({'d':4, 'e': 5})
db.things.find({'a':1})
we are in a complete                      environment, so we can do anything that is supported by the V8 javascript engine
for (var i = 0; i <= 10; i++) { db.things.insert({'x':i})}
JSON
basic structure
human readable format
key/value pairs
ObjectId field unique across system
value types
many different value types
you can have same keys with different types
basic nesting
nested array: 'colors' : ['red','black']
nested object (with attributes with key/values)
deep nesting
students with names and activities
you can show it like a javascript object
and modifty it as a json object
installing node.js
install on Mac
nodejs.org
click install
run through it
test
node
console.log("hello world");
install on windows
nodejs.org
download, install
go to: C:\Program Files\nodejs\
node.exe
console.log('hello world');
asynchronous vs. synchronous
two ways of handling operations that don't require active work on the currently running thread or process
usually these are referring to     
mongo shell is                        while node.js is                         
mongo shell
var doc = db.coll.findOne();
printjson(doc);
node.js
overhead code to connect to db
not getting a return value but passing a                  function, passing an err and document value
...function(err,doc) {
db.close();
advantage of asynchronous is that it can handle a            number of users
the mongo shell              other users until the values come back from the db
run it:
mongo script.js
node app.js
helloworld server in node.js
console.log('testing');
now make web server
var http = require('http');
var server = http.createServer(function (request, response) {...
then http://localhost:8000/
see: howtonode.org/hello-node
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