This is an opinionated simple mongoose connection package. It assumes:
modreal/configand have a
config/mongo.jsonwith db urls
modreal/loggerfor logging with loggly
It handles closing the connection when the script is killed, and giving error messages when it can't connect.
config/mongo.json file, and add to it something like:
Then install mongoose-connection:
$ npm install modreal/mongoose-connection --save
Require it, and add your callback to the connection:
# coffeescriptconnection = require 'modreal-mongoose-connection'connectionon 'connected'-># start app
The package checks for a global mongoose library as well.
global.mongoose = require('mongoose')// laterconnection.mongoose == global.mongoose
AJ Ostrow, November 2013