DubHacks
10.16.2014
var data = readFromDatabase();
print(data);
doSomethingUnrelated();
readFromDatabase({
print(data);
}
doSomethingUnrelated();
cd p3/source/1/
node server.js
npm install -g express
var express = require('express');
var app = express();
app.get('/hello.txt', function(req, res){
res.send('Hello World');
});
app.listen(1337);
console.log('Listening on port 1337');
request and response objects and a next function.
express --help
Usage: express [options] [dir]
Options:
-h, --help output usage information
-V, --version output the version number
-s, --sessions add session support
-e, --ejs add ejs engine support (defaults to jade)
-J, --jshtml add jshtml engine support (defaults to jade)
-H, --hogan add hogan.js engine support
-c, --css add stylesheet support (less|stylus) (defaults to plain css)
-f, --force force on non-empty directory
express -s (cd p3/source/2) npm install node app.js
{
_id: 1234,
author: { name: "Bob Davis", email : "bob@bob.com" },
date: { $date: "2010-07-12 13:23UTC" },
location: [ -121.2322, 42.1223222 ],
comments: [
{ user: "jgs32@hotmail.com",
upVotes: 22,
downVotes: 14,
text: "Great point! I agree" },
{ user: "holly.davidson@gmail.com",
upVotes: 421,
downVotes: 22,
text: "You are a moron" }
]
}
mongod // start the mongo server
mongo // start the CLI
help // show help contents
show collections
use newdb // make the DB on the fly
show collections // show the collections in the DB
db.collection1.save({1: 'a', 2: 'b'});
db.collection1.find(); // return all documents
db.collection1.find({1: 'a'}); // search for documents
npm install mongoose
@GrantTimmerman
Questions?