mongoose-stats

1.0.2 • Public • Published

mongoose-stats

mongoose stats plugin

Build Status npm Github Releases

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
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);

Readme

Keywords

none

Package Sidebar

Install

npm i mongoose-stats

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

12.9 kB

Total Files

8

Last publish

Collaborators

  • tree.xie