Skip to content

klei/mongoload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoload

A small and simple Mongoose model loader/initiator

Installation

npm install mongoload

Usage

index.js:

var mongoload = require('mongoload'),
    mongoose = require('mongoose');

// connect mongoose as usual...

mongoload.bind(mongoose).load({pattern: __dirname + '/models/*.js'});

./models/MyModel.js:

module.exports = function (mongoose, modelName) {
  // Define your mongoose model as usual...
  var schema = mongoose.Schema({
    name: String
  });
  // `modelName` in here will be "MyModel"
  mongoose.model(modelName, schema);
};

License

MIT

About

A small and simple Mongoose model loader/initiator

Resources

Stars

Watchers

Forks

Packages

No packages published