1. mongodb-connection-string-url
MongoDB connection strings, based on the WhatWG URL API
mongodb-connection-string-url
Package: mongodb-connection-string-url
Created by: mongodb-js
Last modified: Wed, 17 Jan 2024 12:36:33 GMT
Version: 3.0.0
License: Apache-2.0
Downloads: 13,486,319
Repository: https://github.com/mongodb-js/mongodb-connection-string-url

Install

npm install mongodb-connection-string-url
yarn add mongodb-connection-string-url

mongodb-connection-string-url

MongoDB connection strings, based on the WhatWG URL API

 import ConnectionString from 'mongodb-connection-string-url';

const cs = new ConnectionString('mongodb://localhost');
cs.searchParams.set('readPreference', 'secondary');
console.log(cs.href); // 'mongodb://localhost/?readPreference=secondary'

Deviations from the WhatWG URL package

  • URL parameters are case-insensitive
  • The .host, .hostname and .port properties cannot be set, and reading
    them does not return meaningful results (and are typed as neverin TypeScript)
  • The .hosts property contains a list of all hosts in the connection string
  • The .href property cannot be set, only read
  • There is an additional .isSRV property, set to true for mongodb+srv://
  • There is an additional .clone() utility method on the prototype

LICENSE

Apache-2.0

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code