@mongodb-js/compass-connect

Connection Screen Plugin that supports Compass

Usage no npm install needed!

<script type="module">
  import mongodbJsCompassConnect from 'https://cdn.skypack.dev/@mongodb-js/compass-connect';
</script>

README

Compass Connect

This plugin is the initial connection screen dialog that appears when you open MongoDB Compass.

Usage

There are two ways in which you can connect to your desirable database: fill in connection fields manually or connect via a connection string (URI).

Connecting via URI

A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.

The standard MongoDB URI connection scheme has the form:

mongodb://[username:password@]host1[:port1][,...hostN[:portN]]][/[database][?options]]

And includes the following components:

mongodb:// -  A required prefix to identify that this is a string in the standard MongoDB connection format.

username:password@ - Optional authentication credentials. If specified, the client will attempt to log in to the specific database using these credentials after connecting.

host[:port] - The host (and optional port number) where the mongod instance (or the mongos instance for a sharded cluster) is running. You can specify a hostname, IP address, or UNIX domain socket. It can contain as many hosts as appropriate for your deployment topology.

/database - The optional name of the database to authenticate if the connection string includes authentication credentials in the form of username:password@.

?<options> - The optional query string that specifies connection string options as <name>=<value> pairs.

Here is some example of MongoDB URI:

mongodb://myDBReader:P%40ssw0rd@mongodb0.example.com:27017/admin?replicaSet=myRepl

uri-view

Connecting via the form

Users can switch to the form view by clicking "Fill in connection fields individually" on the top right corner of the screen. The connection form attributes are split into "Hostname" and "More options" views. On the first view users can enter hostname, port, indicate whether it is SRV record or regular one and specify the authentication mechanism. On the second view, a request can be decorated with additional connection options such as read preference, SSL method or SSH tunnel.

form-view