does-index-exist
Checks whether an index exists on a MongoDB collection
Installation
npm install does-index-exist --save
Usage
var doesIndexExist = MongoClient = MongoClient collection = 'collection' MongoClient
var indexExist = doesIndexExist(options)
Options must include:
connection
- a database connection returned fromMongoClient.connect
collection
- the collection name to check for the index
This returns a function which is called like so:
indexExist(cb)
cb
is the callback for when the query is complete, called withcb(err, exists)
. err is any mongo errors, exists is a boolean