mongoload

0.1.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i mongoload

Weekly Downloads

7

Version

0.1.0

License

MIT

Last publish

Collaborators

  • joakimbeng