Hackernoon logoTips and Ticks with MustacheJS, MongoDB, NodeJS & Mlab. by@ethan.jarrell

Tips and Ticks with MustacheJS, MongoDB, NodeJS & Mlab.

image
Ethan Jarrell Hacker Noon profile picture

Ethan Jarrell

Developer

This is a project I’ve been working on for some time, and uses several different technologies.

1 ) NodeJS — Back End

2) MustacheJS — Front End

3) Database — MongoDB & Mongo Compass & Robo3T

4) Deployment — Heroku & Mlab

Here are some of the issues I ran into, and some considerations to keep in mind if you are planning a similar project, or deciding to use one of these technologies.

Date & Timestamp: One issue I ran into recently with this project, was the inability of Mustache to do any date formatting. The solutions to go around this are often clunky. From what I’ve heard, handlebars has better date formatting than mustache, and so if you are deciding on a templating engine that requires some sort of a date or timestamp, Mustache might not be your best choice.

Referencing & Population: Another issue I found with this project dealt with referencing and population. The only referencing I was doing were with 1 to 1 relationships, which I could do just by including the reference in the model. I also attempted to do a similar reference and population where there was a one to many and many to many relationship. This proved to be more difficult, and I was able to make a work-around, but found that these complex operations in MongoDB don’t always work well. If you’re planning a project that requires a database, and the database collections/tables require several associations, it’s probably going to be easier to go with a relational database instead of a document based database.

Deploying with mlab: mlab offered very easy integration with my app. My models and routes had already been created by the time I tried to connect mlab, so it was just a matter of changing the connections and ports, once my mlab account was set up. I would highly recommend it for any MongoDB/Heroku projects. The sandbox database is free, with limited storage, which worked out fine for me. It’s also easy to add additional users, if your project is a collaborative one.

Database Visualization: I actually looked into other products that Mongo offers, like Compass and Atlas. I was initially going to use Atlas for my online database, but chose Mlab instead, because it seemed to be easier to work with Mlab if you had already deployed your app to Heroku, which I had. I think pricing and structure are similar though. I did, however, get a chance to use Mongo Compass, for local database visualization. Before Compass, I had been using Robo3T for database visualization. And let me just say, there is no comparison. Robo3T is very minimalistic, where Compass allows you to see much more, and interact with the database locally much more easily.

Anyway, those are just a few of the issues and discoveries I found along the way. Hopefully you can find that information helpful. Below is a link to the deployed stat-tracker, so you can sign up, test it out, and give me some feedback. My long term goal is to build out some visualizations for the statistics, so that you could see a graph of when you do certain activities, or how long you spend on certain activities. But any feedback on the simple version here would be much appreciated. I also included the git hub, so feel free to check that out as well. Thanks!

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.