Created
August 14, 2012 19:53
-
-
Save cdolivares/3352248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#connectDb.coffee | |
module.exports = (mongoString) -> | |
mongoose = require 'mongoose' | |
db = mongoose.createConnection mongoString | |
return db | |
#dbConfig.coffee | |
module.exports = (mongoInstance) -> | |
models = {} | |
mongoInstance.model "youModel", youSchema | |
models.youModel = mongoInstance "youModel" | |
#CONFIG DB HERE | |
return models | |
#app.coffee | |
db = require('connectDb)("mongoString") #require returns a function. the second parenthesis executes function | |
dbWithModels = require('dbConfig')(db) | |
dbWithModels.youModels.find etc.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment