mongodb-connection-string-url
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i mongodb-connection-string-url

Weekly Downloads

3,195,364

Version

3.0.0

License

Apache-2.0

Unpacked Size

38.4 kB

Total Files

10

Last publish

Collaborators

  • orechova
  • himanshusinghs
  • c-buckingham
  • mongo-j
  • mabaasit
  • alexander_schroll
  • chuck.kalmanek
  • mongodb-js-user
  • rueckstiess
  • durran
  • lerouxb
  • fredtruman
  • mbroadst
  • hswolff
  • satyasinha
  • matt_d_rat
  • rhysm
  • tomhollander
  • alena.khineika
  • jeff-allen-mongo
  • mmarcon
  • jonathan.balsano
  • mongodb-build
  • jack.weir
  • stennie
  • mcasimir
  • kristina.stefano
  • jarjee
  • shaketbaby
  • devtoolsbot
  • addaleax
  • gribnoysup
  • mutukrish