MongoDB connection strings, based on the WhatWG URL API
npm install mongodb-connection-string-urlMongoDB connection strings, based on the WhatWG URL API
``js
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'
`
- URL parameters are case-insensitive
- The .host, .hostname and .port properties cannot be set, and readingnever
them does not return meaningful results (and are typed as in TypeScript).hosts
- The property contains a list of all hosts in the connection string.href
- The property cannot be set, only read.isSRV
- There is an additional property, set to true for mongodb+srv://.clone()` utility method on the prototype
- There is an additional
Apache-2.0