Mongodb + Nodejs + Express + Mongoose

Experiments with Mongodb, Nodejs, Express and Mongoose.

Building on my previous experiments with Mongodb, I have put together some code to expose my database via RESTful services. All the code base and instructions are on github at

One design change I made to the Mongodb database was to have the the results of the MapReduce functions stored in separate collections. This allow for faster response times and you probably will not be running MapReduce in real time anyways. Though with new innovations even that may be possible (using an incremental map reduce design pattern).

If you want to get up and running with the code follow these instructions…

  • Install Mongdb, Nodejs, Express and Mongoose. The latter two you can use the node package manager (npm install).
  • Download the presidential election contributions data file from This is real data with real people names (maybe even yours if you contributed).
  • Run mongoimport to import the data into a database called contributionsdb and collection named contribution.
  • Download (clone) the code from github (URL provided above).
  • Warning. The code on github uses java field naming conventions for the various attributes in the database. Mongoimport will use the named columns in the first line of the excel data file (which has column names with underscores). So either rename the columns to java style before you import or change the code to have the correct names from the data file. I will try to fix this in the github code sometime. For now please remember this otherwise your code will not run.
  • Rest of the instructions are on github.

I am having some difficulty forming an opinion on nodejs. But the set of frameworks I used (post initial learning curve) allowed me to express myself a lot more elegantly and with very little code. That I like.