When done, http://hci.st/lab-submit.

1


2


3

Stretch Goals

Add comments to your projects.

Do this by adding a new schema and linking it to the project schema


4

Video


5


6


7


8


9


10


11


12


13


14


15


16


17


18


19

Video


20


21

Code

newPost.save(afterSaving);

function afterSaving(err) { // this is a callback
  if(err) {console.log(err); res.send(500); }
  res.redirect('/');
}

22


23


24


25


26


27

Video


28


29


30

Mongoose cheatsheet


31


32

Video


33


34

Terminal

$ bash lab7/check-setup.sh

Debug

I got the error

bash: lab7/check-setup.sh: No such file or directory

Make sure you're in your 'introHCI' directory and that you've cloned lab7 here.


35

Terminal

$ sudo bash lab7/check-setup.sh

Debug

What's the vagrant password?

vagrant


36


37

Debug

When I run node app.js I get the following error

Error: failed to connect to [localhost:xxxxx]

Mongo isn't running! Did you remember to run the check-setup.sh script?


38


39


40


41

Debug Hints

I restarted the server, but nothing shows!

In index.js, add a console.log(projects) inside renderProjects. Is your data formatted correctly? Perhaps you need to change the schema. Don't forget to rerun node initDB.js after changing your schema.


42


43


44

Debug

I can't access res in my callback.

You need to declare the callback function within the projectInfo function to get access to res.


45

Video

Debug Hints

I console.log()ed the data and it looks correct, but wont render!

Hint:find() returns an array of results.


46


47


48

Video

Debug Hints

Doesn't work and I can't findout why!

In your callback, make sure there's a 'if (err) { console.log(err) }'. What does the console output say?

Callback Structure

function deleteCallback(err) {
  if(err) { console.log(err); }
  ...
}

49


50


51

Video

Debug Hints

Doesn't work and I can't findout why!

In your callback, make sure there's a 'if (err) { console.log(err) }'. What does the console output say?

Callback Structure

function addCallback(err) {
  if(err) { console.log(err); }
  ...
}

52


53

GitHub - Commit

git status
git add ...
git commit -m "putting it together lab"

Github - Push

git push

54

Video


55

Heroku - Create

heroku create newapplicationname

Heroku - Addon for Mongo

heroku addons:add mongolab

Heroku - Push

git push heroku master

Heroku - Initialize the Database

heroku run node initDB.js

56


57


When done, submit at http://hci.st/lab-submit.