mongoose-model-loader
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -21,3 +21,8 @@ | ||
debug('loading model %s', modelName) | ||
mongoose.model(modelName, new Schema(model)) | ||
if (!(model instanceof Schema)) { | ||
model = new Schema(model) | ||
} | ||
mongoose.model(modelName, model) | ||
} | ||
@@ -24,0 +29,0 @@ }) |
{ | ||
"name": "mongoose-model-loader", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Load Mongoose models from a directory.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# mongoose-model-loader | ||
Load Mongoose models from a directory | ||
## Installation | ||
$ npm install mongoose-model-loader | ||
## Usage | ||
```js | ||
var loader = require('mongoose-model-loader') | ||
var mongoose = require('mongoose') | ||
// Load models from a directory | ||
loader(__dirname + '/models') | ||
// Access models | ||
var MyModel = mongoose.model('MyModel') | ||
var AnotherModel = mongoose.model('AnotherModel') | ||
``` | ||
## License | ||
MIT |
@@ -20,3 +20,3 @@ | ||
before(function () { | ||
loader(__dirname + '/models') | ||
loader(__dirname + '/fixtures/models') | ||
}) | ||
@@ -39,2 +39,6 @@ | ||
}) | ||
it('should load a model that is of type Schema', function () { | ||
mongoose.model('Account').should.exist | ||
}) | ||
}) |
4066
9
137
23