Sunday, January 19, 2014

Lesson 7: Angularjs/Nodejs/MongoDB Tutorial: Hooking up Node REST server to mongoDB using mongoose

In Lesson 6, we created unit test specs for both our client and server. So far, we have a fully working and tested CRUD for devices. But, the server is still using a static javascript array to hold the list of devices. Its now time to refactor our server side code and hook it up to mongodb using mongoose framework. Since we have good tests, we should feel comfortable in refactoring the code base.

Installing and starting mongodb

  1. brew update
  2. brew install mongodb
  3. mongod&

STOPPED DEVELOPMENT OF THIS IN ANGULAR. Currently, I am developing in Meteorjs framework and its a completely refreshing way to build fully functional websites. Check out the new post regarding meteor.

Meteorjs is way better than Angularjs

After going through the AngularJS tutorials and working through the Device Management app, I decided to redo the example app in Meteor framework. What a refreshing change.... I dabbled in Meteorjs when it was v.0.3 and found that it was not mature enough. A year later, it has significantly improved and the current version meteor 0.7.0.1 is pretty robust. There are also some excellent books & tutorials that help decrease the learning curve significantly on Meteor.

Angularjs on the other hand is still as cumbersome as ever. Once you get past the cool templating schemes of angular, writing even a small application takes an inordinate amount of time. Documentation is severely lacking and the dependency injection constructs get so messy that it hurts my eyes to look at them.

Compare the following to add a device:
-----

-----

Meteor is extremely well integrated full-stack web development solution from front to back. Client side templating, packaging, accounts-ui, caching, reactive response. Server side database integration, reactive & collections.

Meteor collections takes care of both the client and server side code, has a pretty clean model for templating and the meteor packages are a god send. Meteor accounts-ui package provides an out of the box secure authentication model with integration with various provides like google, facebook, github etc. All with 3 lines of code.

Everyone's mileage will vary, but for me Meteor is a very refreshing fullstack web development environment. Its easy to learn, fun to develop in and is being actively worked on by some of the smartest people in the industry. Looks like the roadmap is solid and is being executed on.

If you want to view the device management app in Meteor checkout https://github.com/sunkay/device-safe

If you want to view the same app written in Angular checkout: https://github.com/sunkay/cotd