Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

npm/mongodb-connection-string-url package ported for Deno

License

Notifications You must be signed in to change notification settings

erfanium/mongo_connection_string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo_connection_string

MongoDB connection strings, based on the WhatWG URL API

import ConnectionString from "https://deno.land/x/mongo_connection_string/mod.ts";

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