Moved ref function

I've moved the ref function away from mongoose and created dbHelper.js to hold database related helper functions. Polluting the mongoose object is not considered good practice.

I'm sorry for the double commit, I'm new to collaboration on github and i've had problems with commiting.