1.0.1 • Published 5 years ago

mongoose-query-counter v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

mongoose-query-counter

Query counter for mongoosejs

Maintainability Test Coverage

Features

  • Query type counter: You are able to measure, the queries on your collection by type.

Installation

npm install mongoose-query-counter

Usage

	var mongoose = require('mongoose')
	var Schema = mongoose.Schema
	var audit = require('mongoose-audit')

	var blogSchema = new Schema({
		name: String,
		title: String
	})

	var connection = mongoose.createConnection('mongodb://localhost/test')

	audit.initialize(connection, 'Blog')
	blogSchema.plugin(audit.plugin)

	var  = connection.model('Blog', blogSchema)
	var article = new Blog({title: 'test Title1', name: 'testname'})

Results

Every schema has a collection with the prefix Audit_. This collection collects the call numbers for every query type.

Example record from Audit collection

	{
	    "functionality" : "save",
	    "counter" : 1
	}