Heroku + Node.js + MongoDB (featuring mongoose)

This is the next post in my series around Heroku + Node.js + MongoDB. In my original post I explored the node-mongodb-native driver, which I then followed with Mongoskin. In this post I’ll provide an example for Mongoose.

Again I won’t reiterate the steps to deploy the code. They are the same as the original post, only this time clone the code from this repository:

git@github.com:p15martin/BlogMongoDbMongoose.git

Comments on the code

So up-front I will say Mongoose gives me that warm old-school feeling from my JEE days. There is that sense of coming home and being snuggled up in the data access layer with my separation of concerns, and using my object relational mapping tool.

In contrast to Mongoskin you certainly need to write some additional code, but the intent is clear and the code readable.

The documentation is also great for Mongoose. Keep up the great work!

Conclusion

All three libraries are fantastic, as is Heroku + Node.js + MongoLab + MongoDB. Everything just works, I didn’t encounter any issues. With all three libraries I was able to quickly write my code and see it running in the cloud.

I think the choice of library is very much one of style, with a bias towards either Mongoskin or Mongoose, which I believe are both built on the node-mongodb-native driver.

With that said my examples are simple. I am only demonstrating that it can work and my code does no more than insert a document in the database. I’ve not thought about how these libraries would fit within a much larger codebase, nor have I looked at the robustness of the code or considered error handling. I am working on an extended example around Mongoose to show a more complex application. I will share it once it is complete.

I am encouraged by the fact that it just works and at how accessible the cloud has made technology. Now I can focus on just writing code. How cool is it that I can add a database to my app by simply saying: heroku addons:add mongolab:starter

Advertisements

2 thoughts on “Heroku + Node.js + MongoDB (featuring mongoose)

  1. Hey! Just found this blog on a google search for npm packages. I know this is an old(er) post, but I’m learning mongoose right now and

    “I am working on an extended example around Mongoose to show a more complex application. I will share it once it is complete.”

    piqued my interest.

    Is there anything you could share on this? I couldn’t find any more posts related to it under the mongoose tag.

  2. /dev | MEAN 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s