Skip to content

Instantly share code, notes, and snippets.

@sadasant
Created June 2, 2012 19:19
Show Gist options
  • Save sadasant/2859635 to your computer and use it in GitHub Desktop.
Save sadasant/2859635 to your computer and use it in GitHub Desktop.
Connecting to mongolabs example
/**
* Dependencies.
*/
var MongoStore = require('connect-mongo')
, mongoose = require('mongoose')
, express = require('express')
, app = module.exports = express.createServer()
/**
* Connecting.
*/
var _s = require('./secret')
mongoose.connect('mongodb:'+_s.mongoUrl)
// Models
var App = {}
App.models = {
users: new mongoose.Schema({
_id : mongoose.Schema.ObjectId
, user : String
, email : String
, password : String
})
}
App.User = mongoose.model('users', App.models.users)
//var test = new App.User({ user: 'test', password: 'test' })
//test.save(function(err){ console.log(err) })
//secret.js
/**
* Secret variables and values.
*
* You have to fill this data with our mongolab account.
*/
exports.db = db
var db = {
db : "database_name"
, host : "???.mongolab.com"
, port : "?????"
, username : "?????????"
, password : "?????????"
, collection : 'collection_name'
}
exports.mongoUrl = db.username+":"+db.password+"@"+db.host+":"+db.port+"/"+db.db;
exports.session = "??????????????";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment