mongodb-connection-string-url

MongoDB connection strings, based on the WhatWG URL API

Apache-2.0 27 个版本
安装
npm install mongodb-connection-string-url
yarn add mongodb-connection-string-url
pnpm add mongodb-connection-string-url
bun add mongodb-connection-string-url
README

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

版本列表
7.0.1 2026-01-26
7.0.0 2025-11-05
4.0.0-alpha 2025-10-21
3.0.2 2025-01-14
3.0.1 2024-05-10
3.0.0 2023-11-02
2.6.0 2022-11-28
2.5.4 2022-09-30
2.5.3 2022-07-22
2.5.2 2022-02-25
2.5.1 2022-02-23
2.5.0 2022-02-23
2.4.2 2022-02-02
2.4.1 2021-12-21
2.4.0 2021-12-21
2.3.2 2021-12-13
2.3.1 2021-12-13
2.3.0 2021-12-13
2.2.0 2021-11-15
2.1.0 2021-09-21
2.0.0 2021-08-09
1.1.2 2021-08-06
1.1.1 2021-08-06
1.1.0 2021-07-30
1.0.2 2021-07-30
1.0.1 2021-07-06
1.0.0 2021-06-15