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

mongodb-connection-string-url

Package Overview
Dependencies
Maintainers
33
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-connection-string-url

MongoDB connection strings, based on the WhatWG URL API

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6M
decreased by-1.17%
Maintainers
33
Weekly downloads
 
Created

What is mongodb-connection-string-url?

The mongodb-connection-string-url npm package is designed to parse and manipulate MongoDB connection strings according to the MongoDB connection string specification. It provides a convenient way to work with MongoDB connection strings, allowing users to easily read, modify, and construct connection strings in a programmatic way.

What are mongodb-connection-string-url's main functionalities?

Parsing a MongoDB connection string

This feature allows you to parse a MongoDB connection string and access its components, such as hosts, database name, and options.

"const { ConnectionString } = require('mongodb-connection-string-url');\nconst connectionString = new ConnectionString('mongodb://localhost:27017');\nconsole.log(connectionString.hosts); // Outputs: ['localhost:27017']"

Modifying the database name

This feature demonstrates how to modify the database name in a MongoDB connection string using the package.

"const { ConnectionString } = require('mongodb-connection-string-url');\nconst connectionString = new ConnectionString('mongodb://localhost:27017/mydatabase');\nconnectionString.pathname = '/anotherdatabase';\nconsole.log(connectionString.toString()); // Outputs: 'mongodb://localhost:27017/anotherdatabase'"

Adding query parameters

This feature shows how to add query parameters to a MongoDB connection string, which can be used to specify options such as retryWrites.

"const { ConnectionString } = require('mongodb-connection-string-url');\nconst connectionString = new ConnectionString('mongodb://localhost:27017');\nconnectionString.searchParams.set('retryWrites', 'true');\nconsole.log(connectionString.toString()); // Outputs: 'mongodb://localhost:27017/?retryWrites=true'"

Other packages similar to mongodb-connection-string-url

Keywords

FAQs

Package last updated on 10 May 2024

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