🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

mongodb-uri

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-uri

A parser and formatter for MongoDB URIs.

0.9.7
latest
Source
npm
Version published
Weekly downloads
186K
1.6%
Maintainers
1
Weekly downloads
 
Created

What is mongodb-uri?

The mongodb-uri npm package is a utility for parsing and formatting MongoDB URIs. It helps in converting MongoDB connection strings into a more manageable object format and vice versa.

What are mongodb-uri's main functionalities?

Parsing MongoDB URIs

This feature allows you to parse a MongoDB URI string into an object that contains all the components of the URI, such as username, password, host, port, and database.

const mongodbUri = require('mongodb-uri');
const uri = 'mongodb://username:password@host:port/database';
const parsedUri = mongodbUri.parse(uri);
console.log(parsedUri);

Formatting MongoDB URIs

This feature allows you to format an object containing MongoDB URI components back into a URI string.

const mongodbUri = require('mongodb-uri');
const uriObject = {
  scheme: 'mongodb',
  username: 'username',
  password: 'password',
  hosts: [
    { host: 'host', port: 27017 }
  ],
  database: 'database'
};
const formattedUri = mongodbUri.format(uriObject);
console.log(formattedUri);

Handling Multiple Hosts

This feature allows you to parse MongoDB URIs that contain multiple hosts, which is useful for connecting to replica sets.

const mongodbUri = require('mongodb-uri');
const uri = 'mongodb://username:password@host1:27017,host2:27018/database';
const parsedUri = mongodbUri.parse(uri);
console.log(parsedUri);

Other packages similar to mongodb-uri

Keywords

mongodb

FAQs

Package last updated on 11 Jun 2014

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