Skip to content

Instantly share code, notes, and snippets.

/db.js

Created Aug 21, 2013
Embed
What would you like to do?
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