Created
March 30, 2011 22:52
-
-
Save kof/895480 to your computer and use it in GitHub Desktop.
bootstrap file for mongoose models
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
var fs = require('fs'), | |
m = require('mongoose'); | |
fs.readdirSync(__dirname).forEach(function(filename) { | |
var schamaName = filename.replace(/\.js$/, ''), | |
Schema = require('./' + schemaName); | |
m.model(schemaName, Schema); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Schema modules are in the same dir and file names should correspond model name.
// Website.js
var Website = new m.Schema({
title: String,
pages: [Page]
});