mongoose-profiler
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -13,4 +13,7 @@ module.exports = { | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly' | ||
jest: 'readonly', | ||
test: 'readonly', | ||
expect: 'readonly', | ||
beforeEach: 'readonly', | ||
afterEach: 'readonly' | ||
}, | ||
@@ -17,0 +20,0 @@ parserOptions: { |
13
index.js
@@ -1,1 +0,12 @@ | ||
module.exports = require('./lib/core'); | ||
const Profiler = require('./lib/profiler'); | ||
module.exports = options => { | ||
const profiler = new Profiler(options); | ||
return schema => { | ||
schema.pre('find', profiler.preFunction); | ||
schema.pre('findOne', profiler.preFunction); | ||
schema.post('find', profiler.postFunction); | ||
schema.post('findOne', profiler.postFunction); | ||
}; | ||
}; |
{ | ||
"name": "mongoose-profiler", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A performance tuning tool for Mongoose.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./node_modules/jest/bin/jest.js --coverage", | ||
"coveralls": "./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info" | ||
}, | ||
@@ -23,7 +24,10 @@ "repository": { | ||
"devDependencies": { | ||
"coveralls": "3.0.3", | ||
"eslint": "5.15.3", | ||
"eslint-config-xo": "0.26.0", | ||
"eslint-config-xo-space": "0.21.0", | ||
"jest": "24.7.1", | ||
"mockdate": "2.0.2", | ||
"npm-check-updates": "3.1.7" | ||
} | ||
} |
# mongoose-profiler | ||
[![npm version](https://badge.fury.io/js/mongoose-profiler.svg)](https://www.npmjs.com/package/mongoose-profiler) | ||
[![Coverage Status](https://coveralls.io/repos/github/kelp404/mongoose-profiler/badge.svg?branch=master&a)](https://coveralls.io/github/kelp404/mongoose-profiler?branch=master) | ||
[![CircleCI](https://circleci.com/gh/kelp404/mongoose-profiler.svg?style=svg)](https://circleci.com/gh/kelp404/mongoose-profiler) | ||
This is a [mongoose](https://mongoosejs.com) plugin for tuning performance. | ||
@@ -17,2 +21,3 @@ It will show the [explain results](https://docs.mongodb.com/manual/reference/explain-results/) on the console when the query is slow. | ||
When you execute this query without the index then you will get some messages on the console. | ||
```js | ||
@@ -24,3 +29,2 @@ ProductModel | ||
``` | ||
When you execute this query without the index then you will get some messages on the console. | ||
```base | ||
@@ -93,4 +97,3 @@ Mongoose: 64ms Products.find({ state: 'active', owner: { '$in': [ ObjectId("5c9d9428e7462d3d989cb69b"), ObjectId("5c9d95acea5c9b4036d97c88") ] } }, { skip: 0, limit: 100 }) | ||
## Document | ||
### Options | ||
## mongooseProfiler() | ||
```js | ||
@@ -105,7 +108,8 @@ const mongooseProfiler = require('mongoose-profiler'); | ||
``` | ||
### Options | ||
Name | Type | Default | Description | ||
:-----------------:|:-----------:|:--------:|:-----------: | ||
:------------------|:------------|:---------|:------------ | ||
isAlwaysShowQuery | Boolean | true | | ||
duration | Number | 1000ms | Show the explain result when the query took more than this time.<br/>(The time from `pre()` to `post()`.) | ||
totalDocsExamined | Number | | Show the explain result when the query examined documents more than this number. | ||
level | String | COLLSCAN |ALL: Show the explain result of all queries.<br/>COLLSCAN: Show the explain result when the mongodb scan collections. | ||
level | String | COLLSCAN |`ALL`: Show the explain result of all queries.<br/>`COLLSCAN`: Show the explain result when the mongodb scan collections. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
24715
13
558
1
112
7
1