# mongoose-simple-loader

> A node module to load mongoose models from a given directory dinamically.

Latest version **1.0.2** (published 2016-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-simple-loader
pnpm add mongoose-simple-loader
yarn add mongoose-simple-loader
bun add mongoose-simple-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-10-26 |
| First published | 2016-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Author | Heyde Moura |
| Maintainers | heydemoura |
| Keywords | Mongo, Mongoose, Models, Schema, database, require, dynamic, directory |

## Links

- npm: https://www.npmjs.com/package/mongoose-simple-loader
- npm.io page: https://npm.io/package/mongoose-simple-loader

## Dependencies (1)

- [mongoose](https://npm.io/package/mongoose.md) ^4.6.5

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2016-10-26
- 1.0.1 — 2016-10-26
- 1.0.0 — 2016-10-26

## README

# mongoose-simple-loader
Load mongoose models from a given directory dinamically.

This module will help you import all of your modules from a given directory, automatically, into your scripts. You will be able to access them as properties of the returned object.

# Requirements
Mongoose
NodeJS >= 4.6.0

# Installation & Use
To install, go with the regular:
```
npm install mongoose-simple-loader
```
### Usage

Require the module passing the first argument as your models directoty, and then pass your connection string through the .connect() method.
```javascript
// Load your models
var db = require('mongoose-model-loader')(__dirname + '/../models_directory/');

// Connect to Database
// Just an alias for mongoose.connect()
db.connect(uri, options);

db.My_model().find().then(function(item) {
  // Do stuff
});
```

Your models will me loaded as properties of the module object, named after the respective filename. 

Eg.:

| Filename      | Model          |
| ------------- |:--------------:|
| Users.js      | db.Users.js    |
| TB_Users.js   | db.TB_Users.js |

I hope you got the idea.

### Share your love!
Feel free to send any kind of feedback.

---
_Source: https://npm.io/package/mongoose-simple-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
