# egg-mongoose-mock

> egg mongoose using mock server plugin

Latest version **3.3.14** (published 2020-10-30) · 0 weekly downloads

## Install

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

## 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 | 3.3.14 |
| Published | 2020-10-30 |
| First published | 2020-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 4 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | ewinds |
| Keywords | egg, egg-model, mongoose, eggPlugin, egg-plugin |

## Links

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

## Dependencies (4)

- [mongoose](https://npm.io/package/mongoose.md) ^5.10.9
- [await-first](https://npm.io/package/await-first.md) ^1.0.0
- [@types/mongoose](https://npm.io/package/@types/mongoose.md) ^5.3.24
- [mongodb-memory-server](https://npm.io/package/mongodb-memory-server.md) ^6.9.2

## 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
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 3.3.14 (latest) — 2020-10-30
- 3.3.13 — 2020-10-29
- 3.3.12 — 2020-10-29
- 3.3.10 — 2020-10-29
- 3.3.9 — 2020-10-29
- 3.3.8 — 2020-10-29
- 3.3.7 — 2020-10-29
- 3.3.6 — 2020-10-29
- 3.3.5 — 2020-10-29
- 3.3.4 — 2020-10-28
- 3.3.3 — 2020-10-28
- 3.3.2 — 2020-10-28
- 3.3.1 — 2020-10-27
- 3.3.0 — 2020-10-27

## README

# egg-mongoose-mock
[![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-mock.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-mongoose-mock
[travis-image]: https://img.shields.io/travis/ewinds/egg-mongoose-mock.svg?style=flat-square
[travis-url]: https://travis-ci.org/ewinds/egg-mongoose-mock
[codecov-image]: https://img.shields.io/codecov/c/githubewinds/egg-mongoose-mock.svg?style=flat-square
[codecov-url]: https://codecov.io/github/ewinds/egg-mongoose-mock?branch=master
[david-image]: https://img.shields.io/david/ewinds/egg-mongoose-mock.svg?style=flat-square
[david-url]: https://david-dm.org/ewinds/egg-mongoose-mock
[snyk-image]: https://snyk.io/test/npm/egg-mongoose-mock/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-mongoose-mock
[download-image]: https://img.shields.io/npm/dm/egg-mongoose-mock.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-mongoose-mock

Egg's mongoose plugin for unit testing.

## Install

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

## Configuration

Change `{app_root}/config/plugin.unittest.js` to enable `egg-mongoose-mock` plugin:

```js
exports.mongoose = {
  enable: false,
  package: 'egg-mongoose',
};
exports.mongooseMock = {
  enable: true,
  package: 'egg-mongoose-mock',
};
```

## Simple connection

### Config

```js
// {app_root}/config/config.unittest.js
exports.mongoose = {
  client: {
    plugins: []
  }
};
exports.mongooseMock = {
  options: {
    autoReconnect: true,
    useNewUrlParser: true,
    useFindAndModify: false,
    useCreateIndex: true,
    useUnifiedTopology: true,
  },
};
```

### Example

```js
// {app_root}/app/model/user.js
module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const UserSchema = new Schema({
    userName: { type: String  },
    password: { type: String  },
  });

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

// {app_root}/app/controller/user.js
exports.index = function* (ctx) {
  ctx.body = yield ctx.model.User.find({});
}
```

### Default config

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

## Questions & Suggestions

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

## Contribution

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

## License

[MIT](LICENSE)

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