# tmc-egg-mongoose

> [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][down

Latest version **1.0.4** (published 2017-07-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install tmc-egg-mongoose
pnpm add tmc-egg-mongoose
yarn add tmc-egg-mongoose
bun add tmc-egg-mongoose
```

## 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.4 |
| Published | 2017-07-31 |
| First published | 2017-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | jasonwx |

## Links

- npm: https://www.npmjs.com/package/tmc-egg-mongoose
- Repository: https://github.com/jasonwwl/egg-mongoose
- Homepage: https://github.com/jasonwwl/egg-mongoose#readme
- Issues: https://github.com/jasonwwl/egg-mongoose/issues
- npm.io page: https://npm.io/package/tmc-egg-mongoose

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^4.11.4
- [await-event](https://npm.io/package/await-event.md) ^2.1.0

## Recent versions

- 1.0.4 (latest) — 2017-07-31
- 1.0.3 — 2017-07-31
- 1.0.2 — 2017-07-25
- 1.0.1 — 2017-07-25
- 1.0.0 — 2017-07-25

## README

# egg-mongoose
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/egg-mongoose.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-mongoose
[travis-image]: https://img.shields.io/travis/eggjs/egg-mongoose.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs/egg-mongoose
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mongoose.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/egg-mongoose?branch=master
[david-image]: https://img.shields.io/david/eggjs/egg-mongoose.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs/egg-mongoose
[snyk-image]: https://snyk.io/test/npm/egg-mongoose/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-mongoose
[download-image]: https://img.shields.io/npm/dm/egg-mongoose.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-mongoose

Egg's mongoose plugin.

## Install

```bash
$ npm i egg-mongoose --save
```

## Usage

```js
// {app_root}/config/plugin.js
exports.mongoose = {
  enable: true,
  package: 'egg-mongoose',
};
```

## Configuration

```js
// {app_root}/config/config.default.js
exports.mongoose = {
  url: 'mongodb://127.0.0.1/example',
  options: {}
};
```

see [config/config.default.js](config/config.default.js) for more detail.

## Multi-mongos support

```js
// {app_root}/config/config.default.js
exports.mongoose = {
  url: 'mongodb://mongosA:27501,mongosB:27501',
  options: {}
};
```

## Example
```js
// app/model/user.js
module.exports = app => {
  const mongoose = app.mongoose;
  const UserSchema = new mongoose.Schema({
    userName: { type: String  },
    password: { type: String  }
  });

  return mongoose.model('User', UserSchema);
}

// app/controller/user.js
exports.index = function* (ctx) {
  ctx.body = yield ctx.model.User.find({});  // you should use upper case to access mongoose model
}
```

## Questions & Suggestions

Please open an issue [here](https://github.com/eggjs/egg-mongoose/issues).

## Contribution

If you are a contributor, follow [CONTRIBUTING](https://eggjs.org/zh-cn/contributing.html).

## License

[MIT](LICENSE)

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