# mongoose-stats

> mongoose stats

Latest version **1.0.2** (published 2018-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-stats
pnpm add mongoose-stats
yarn add mongoose-stats
bun add mongoose-stats
```

## 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 | 2018-06-29 |
| First published | 2018-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | tree.xie |

## Links

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

## Recent versions

- 1.0.2 (latest) — 2018-06-29
- 1.0.1 — 2018-04-10
- 1.0.0 — 2018-04-05

## README

# mongoose-stats

mongoose stats plugin

[![Build Status](https://travis-ci.org/vicanso/mongoose-stats.svg?branch=master)](https://travis-ci.org/vicanso/mongoose-stats)
[![npm](http://img.shields.io/npm/v/mongoose-stats.svg?style=flat-square)](https://www.npmjs.org/package/mongoose-stats)
[![Github Releases](https://img.shields.io/npm/dm/mongoose-stats.svg?style=flat-square)](https://github.com/vicanso/mongoose-stats)


## API

stats event data

- `collection` the mongodb collection
- `op` the op function
- `use` the time consuming of function
- `size` the record count of function
- `options` the query options, optional
- `conditions` the query conditions, optional
- `fields` the query fields, optional
- `update` the update data, optional


```js
const mongoose = require('mongoose');
const mongooseStats = require('mongoose-stats');

const {Schema} = mongoose;
const schema = new Schema({
  name: String,
}, {
  timestamps: true,
});
const Book = mongoose.model('Book', schema);
schema.plugin(mongooseStats, {
  collection: 'Book',
});
schema.on('stats', (data) => {
  // { collection: 'Book', op: 'save', use: 36, size: 1 }
  console.info(data);
});

new Book({
  name: '测试',
}).save().then(() => {

}).catch(console.error);
```

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