Skip to content

davkorss/mongodb-index-inspector

Repository files navigation

MongoDB Index Inspector

Log warnings about the missing MongoDB indexes.

Support

MongoDB Node.JS Driver 2.2

MongoDB 3.4

Installation

npm install mongodb-index-inspector --save
npm install [email protected] --save

Usage

TypeScript

import { MongoDBIndexInspector, MongoDBFilter } from 'mongodb-index-inspector';

async function inspect (): void {
    const filter: MongoDBFilter = { username: 'davkorss', password: 'The safest password in the world :3' };
    const inspector: MongoDBIndexInspector = new MongoDBIndexInspector(collection);
    await inspector.inspect(filter);
}

inspect();
If the index does not exist, output should be:
'Missing index from filter {"username":"davkorss","password":"The safest password in the world :3"}'

JavaScript

const MongoDBIndexInspector = require('mongodb-index-inspector').MongoDBIndexInspector

async function inspect () {
    const filter = { username: 'davkorss', password: 'The safest password in the world :3' }
    const inspector = new MongoDBIndexInspector(collection)
    await inspector.inspect(filter)
}

inspect()
If the index does not exist, output should be:
'Missing index from filter {"username":"davkorss","password":"The safest password in the world :3"}'

Test

npm test

About

Log warnings about the missing MongoDB indexes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published