mongodb-build-info
Extract information from mongodb's buildInfo
Last updated 3 months ago by lrlna .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mongodb-build-info 
SYNC missed versions from official npm registry.

mongodb-build-info Build Status

Helpful functions to figure out if a connection is on Atlas, Atlas Data Lake, Enterpise, or DocumentDB/CosmosDB.

Usage

const getBuildInfo = require('mongodb-build-info')
const MongoClient = require('mongodb').MongoClient

MongoClient.connect('localhost:27017', function (err, client) {
  const adminDB = client.db('test').admin()
  let buildInfo;

  adminDB.command({ buildInfo: 1 }, {}, parseBuildInfo)
  adminDB.command({ getCmdLineOpts: 1 }, {}, parseCmdLineOpts)

  function parseBuildInfo (err, res) {
    if (err) console.log('Command failed, ', err)
    buildInfo = res

    const { isDataLake, dlVersion } = getBuildInfo.getDataLake(buildInfo)
    const isEnterprise = getBuildInfo.isEnterprise(buildInfo)
  }

  function parseCmdLineOpts (err, res) {
    if (err) console.log('Command failed', err.message)
    
    const { isGenuine, serverName } = getGenuineMongoDB(buildInfo, res)
  }
})

API

getDataLake(buildInfo)

Returns an object:

isDataLake: boolean. dlVersion: version of dataLake, a string.

isEnterprise(buildInfo)

Returns a boolean.

isAtlas(uri)

Returns a boolean.

isLocalhost(uri)

Returns a boolean.

getGenuineMongoDB(buildInfo, cmdLineOpts)

Returns an object:

isGenuine: boolean. serverName: name of the server (mongoDB, cosmosDB, or documentDB).

getBuildEnv(buildInfo)

Returns an object:

serverOs: build's OS version (macOS, linux, windows etc.). serverArch: build's architecture (e.g. x86_64).

Installation

npm install -S mongodb-build-info

License

Apache-2.0

Current Tags

  • 1.1.1                                ...           latest (3 months ago)

3 Versions

  • 1.1.1                                ...           3 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.0                                ...           9 months ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 24
Dependencies (0)
None
Dev Dependencies (4)

Copyright 2014 - 2017 © taobao.org |