mongo-url-parser

1.0.2 • Public • Published

mongo-url-parser

Simple parser for mongodb connection strings.

Usage

npm install --save mongo-url-parser
const parser = require('mongo-url-parser');
const url = 'mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin';
const parsed = parser(url);

parsed now contains the following

{
  usingSrv: false,
  auth: { user: 'myDBReader', password: 'D1fficultP@ssw0rd' },
  server_options: { socketOptions: {} },
  db_options: {
    read_preference_tags: null,
    authSource: 'admin',
    read_preference: 'primary'
  },
  rs_options: { socketOptions: {} },
  mongos_options: {},
  dbName: 'admin',
  servers: [ { host: 'mongodb0.example.com', port: 27017 } ]
}

This is based on the connection string parser from the mongodb driver.

License

Apache 2.0

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.21,220latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.21,220
1.0.121
1.0.00

Package Sidebar

Install

npm i mongo-url-parser

Weekly Downloads

1,241

Version

1.0.2

License

Apache 2.0

Unpacked Size

25.3 kB

Total Files

6

Last publish

Collaborators

  • sulka