MongoDB for Node.js Developers Course

MongoDB University

Recently I completed the MongoDB for Node.js Developers Course from (MongoDB University)[https://university.mongodb]. This is my experience..

Course Overview

It’s a 7 week online course that covers using mongoDB and Node.js. Each week you’ll have 20 – 30 short (5 to 10 minute) video lessons followed by a quiz. The quiz can be multiple choice or writing javascript + mongoDB queries.
The quiz results do not count towards the final grade.
At the end of each week there is a homework assignment to complete and submit for verification.

Expect to spend ~3 hours on lessons and other couple on homework per week. It can be challenging to keep up the momentum of 7 weeks.

Grading

The homework assignments from each week will make up 50% of your final grade. The other 50% for a final exam.
65% is the overall grade you’ll need to hit to pass. Upon passing you’ll get a ‘cert’ from MonogoDB University. I’m expecting to receive mine in the next few weeks. After christmas 🙂

Course Structure

  • Week 1: Introduction – Installing, mongo shell, installing tools, node modules, swig, express
  • Week 2: CRUD – Mongo shell, queries, update, operators etc
  • Week 3: Patterns, case studies, trade offs
  • Week 4: Performance – indexes, monitoring, sharding
  • Week 5: Aggregation Framework – pipeline, SQL comparisons
  • Week 6: Replication and sharding
  • Week 7: Intro to Mongoose and FINAL EXAM

Conclusion

Worth it.
I came to this course with little knowledge of MongoDb. I had done several tutorials + read a couple of books.

However through the lessons, quizzes, homework etc, I picked up a decent bit of practical experience and theoretical knowledge for getting up and running. And if I’m luckily …for scaling out.

Also did I mention it’s a free course?

Part 1: Create a simple blog with Node.js

Hi,

Let’s create a simple blogging system in Node.js.

For part 1 we’ll aim for Create, read, update for blog posts. No comments, authentication, administration just yet. We’ll save that for sebsequent posts.

What we need to begin

Let’s go!

I work on a OSX so please tailor the steps to suit your operating system.

1) Install Geddy MVC
$ sudo npm install -g geddy
Notice the -g here, Geddy should installed globally. It gives command line tools for generating scaffolding and creating MVC parts.  Saves you the hassle, very RoR like here.

2) At this point you have Geddy installed.

Time to generate a skeleton Geddy Application. We’ll call our blog geddy_blog.

$ geddy app geddy_blog
3) Next generate scaffold for your blog posts:

Our blog will have the following fields:

  • ‘title’ which is the default the Geddy will show on the main blog page.
  • ‘body’ the actual text of the blog post
  • ‘status’ published or unpublished

$ geddy scaffold blog title:default body status

You should see the following output:

$ geddy scaffold blog title:default body status
[Added] app/models/blog.js
Creating table for Blog
[Added] test/blog.js
[Added] app/controllers/blogs.js
[Added] Resource blogs route added to config/router.js
[Added] View templates

4) Run geddy from the geddy_blog directory:

$ geddy

At this point you’ll have a CURD for the blog model you just created

Open your browser at http://localhost:4000/blogs

5) Database layer.Install MongoDB server if you haven’t already.

Skip this step if you have.

By default Geddy uses in-memory data storage but we want persistence and so we come to MongoDB.

Install MongoDB, remember I’m on OSX. See MongoDB for further instructions to suit your OS.

$ brew install mongodb

Start your MongoDB server:

$ mongod

7) Time to install mongodb node wrapper. This allows Node.js to talk to you mongoDB server.

$ npm install mongodb-wrapper

8) Configure Geddy to use MongoDB.

Open geddy_blog/config/development.js

Update defaultAdapter = ‘mongo’

Add db: { mongo: { dbname: ‘geddy_blog }

So you’ll development.js looks like this:


var config = {
detailedErrors: true
, debug: true
, hostname: null
, port: 4000
, model: {
defaultAdapter: 'mongo'
}
, db: {
mongo: {
dbname: 'blog_test'
}
}
, sessions: {
store: 'memory'
, key: 'sid'
, expiry: 14 * 24 * 60 * 60
}
};

module.exports = config;
9) Finally Ctrl-C on previous Geddy process and start it again:


$ geddy

Summary:

At this point you have created CRUD for your blog post model, stored in mongo db database.

Geddy is changing pretty pretty fast and this tutorial may be out of date. For more uptodate tutorials, docs please checkout the geddjys.org

For part 2 I hope to create comments for those blog posts.

Good luck!