Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongotoolbox

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongotoolbox

Utility for MongoDB native driver which adds unexisting indexes and removes unused

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Mongotoolbox

MongoDB toolbox for index management and simple connection to authorized database


Using

This utility requires:

  • Node.js >= 6.0.0
  • mongodb driver ^2.2.4

Install package with npm:

npm i -S mongotools

Ensure indexes at collection

const mongotools = require('mongotools');

mongotools.ensureIndex(db.collection('myCollection'))
    .index({ someUniqueIndex: 1 }, { sparse: true, unique: true })
    .writeIndexes();

Connect to database


const mongotools = require('mongotools');

mongotools.connectAndAuth('mongodb://localhost:27017')
    .then((db) => {
        // use connected db object
    });

Connect to database and authenticate


const mongotools = require('mongotools');

const url = 'mongodb://localhost:27017';
const options = { user: 'username', password: 'foo' };

mongotools
    .connectAndAuth(url, options)
    .then((db) => {
        // use connected db object
    });

API

connectAndAuth method

  • connectAndAuth(url: string, options: object)
    • url: mongodb connection string
    • options options for mongodb connect method
      • options.user: username for authentication
      • options.password: password for authentication

EnsureIndex class

  • new EnsureIndex(mongoDbCollection)

    • creates instance of mongodb collection
  • index(definition: string, options: object)

    • definition: object accepted by mongo
    • options: object accepted by mongo
  • writeIndexes()

    • removes unwanted indexes and writes non-existing ones

Keywords

FAQs

Package last updated on 11 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc