Skip to content

Instantly share code, notes, and snippets.

Created August 21, 2013 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/6299143 to your computer and use it in GitHub Desktop.
Save anonymous/6299143 to your computer and use it in GitHub Desktop.
Code modularity / organization
module.exports = function(){
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/app');
var db = mongoose.connection;
var usrSchema = new mongoose.Schema({
user: { type: String, required: true },
password: { type: String, required: true },
DLU: { type: Date }
});
var User = mongoose.model('user', userSchema);
}
require('./db');
/*
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/app');
var db = mongoose.connection;
var usrSchema = new mongoose.Schema({
user: { type: String, required: true },
password: { type: String, required: true },
DLU: { type: Date }
});
var User = mongoose.model('user', userSchema);
*/
User.find(function(err,docs){
console.log(docs);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment