Skip to main content

MongoDB Compass™ Team Collaboration

Summary

Qarbine extends collaboration for modern data and AI teams using popular tools. Developers and analysts rely on vendor desktop or web tools to interact with their databases. However, these tools are typically single-user oriented. This tutorial uses MongoDB Compass as an example tool for team collaboration. The techniques described apply across the board to many other environments.

MongoDB Compass is a MongoDB GUI tool for a developer to query, analyze schemas, optimize indices, and analyze database content. Its aggregation pipeline builder is a very flexible tool to define and understand MongoDB aggregation based queries. For more information see https://www.mongodb.com/products/tools/compass.

Collaborative Compass Work using Qarbine

This document describes how to transform the single-user oriented tool into one that better supports collaborative teamwork. MongoDB Compass provides local storage for your queries. It is a great tool for a single developer to carry out many database activities. However, Compass does not provide a means to share queries and related MongoDB knowledge with peers. This can greatly inhibit team productivity and knowledge sharing- especially with distributed teams.

Qarbine enables queries developed internally within Qarbine and Compass across team members to be easily shared and discovered by others. This improves everyone’s productivity and improves overall application development. This knowledge is especially important as more complex GenAI vector search and other MongoDB features are utilized by modern application developers. The techniques here apply to many other solo database tools as well.

Preparation

The first step is to set up a folder in the Qarbine catalog to share components. Multiple folders can be defined and Qarbine’s Windows Explorer folder metaphor helps teams stay organized. This writeup uses a shared folder, but you can create private ones too.

Sign on to Qarbine and open the Catalog Browser.

  

Determine which folder your team will share Compass oriented knowledge within. In this example a folder is created within the “public” main folder.

  

Enter a folder name

  

The folder is created and selected.

  

Sharing Notes Among Team Members

You can store arbitrary files in the Qarbine catalog including text, JSON, PDF, and even image files. The text file functionality can be used to manage notes, AI prompt templates, and query snippets for yourself and share across team members.

Saving a Text File in the Catalog

The right hand side of the Catalog window has a couple of options for saving files in the catalog.

  

. . .

  

Dragging and dropping a file into the right hand widget above is one simple way. Below is feedback on a dropped file.

  

To save in the catalog click

  

A dialog is shown.

  

. . .

  

The use of the tags will be discussed later. The entry field value is a comma separated value (CSV) list. It is important to have some description text so that catalog searches can find the intended documents. The contents of the files are opaque bits and not searchable by the underlying internal MongoDB database.The catalog searches of “File” entries only look at the names and descriptions

If necessary change the target folder and catalog entry name.
Click

  

The file is saved and the catalog display updated.

  

Creating a Shared Text File

Navigate to the folder intended to contain the text file component.

To create a text file component, right click and choose the menu options shown below.

  

You can optionally use the clipboard’s contents as the file’s initial text.

A dialog is presented.

  

. . .

  

Enter a name and optionally tags.
Click

  

The catalog is refreshed

  

Viewing and Editing the Text Files

In the catalog navigate to the text file entry of interest. The right hand side shows information about the entry with properties similar to other Qarbine components. To edit click the red highlighted button below.

  

The plain text editor dialog appears with the title being the name of the Qarbine File component.

  

The toolbar contains options to download the text, reformat JSON, and validate JSON respectively.

  

The text may be editing and saved by clicking

  

MongoDB Compass Local Query File Assistance

Overview

Besides text, JSON content can also be stored in the Qarbine catalog. This can be useful to save and share MongoDB Compass queries for a team. Recall that MongoDB Compass only runs locally. The location it stores your saves queries is

C:\Users\WINDOWS_USER\AppData\Roaming\MongoDB Compass\SavedPipelines

Importing Compass Queries

In the catalog navigate and select the folder to contain the shared pipeline queries.

  

Click

  

Navigate to your local SavedPipelines folder.

  

Choose a file.

  

Click

  

The right hand side of the page updates.

  

Note that the name of the Compass query is shown as part of the import feedback.

Click

  

A dialog is presented

  

. . .

  

. . .

  

When importing JSON Qarbine if the JSON is a single object with a name field then that value is used as the default File component name and the original file name is set as the default description.

  

You can edit these values as needed including adding your name into the description for cross referencing purposes later.

  

Click

  

The File component is saved in the catalog and the display refreshes.

  

Your team members who log on to Qarbine can now leverage this information you provided and vice versa.

Updating the Catalog Stored MongoDB Queries

Recall that in the importing steps above it was suggested that the description contain a cross reference to the original local file name and the person who imported it into Qarbine. This information is useful when updating catalog content.

Suppose you have made changes to your local Compass query. If you were to begin importing into the same folder and the internal name matches then the save dialog will show.

  

The warning about replacing the File is shown but remember to adjust the tags and the description to include your name and such as desired because the Qarbine file object in the catalog will be completely replaced.

Updating the Local Compass Queries

Navigate to the desired File component within the catalog.

  

The right hand side of the catalog shows the file’s properties.

  

Click on the red highlighted button to download its contents. At this point the description information can be very useful. You likely want to copy the file from your browser’s Downloads folder into the SavedPipelines folder such that the original Compass JSON file is replaced.

Recall the local Compass query folder path is of the form

C:\Users\WINDOWS_USER\AppData\Roaming\MongoDB Compass\SavedPipelines

Back in Compass your updated query should now be available.

Reviewing the Catalog’s Compass Queries

Navigate to the file in the Qarbine Catalog.

Click

  

The JSON dialog is shown.

  

Copying Qarbine Queries to use in Compass

Open Compass.

Navigate to the database of interest.

Navigate to the Qarbine Data Source of interest.
In some cases you can simply copy the query text to the clipboard.

Your query may have variables. You can copy the text as is and adjust things in Compass.

Alternatively, press Alt and click Run.

  

Provide the variables

  

Click

  

A dialog is presented.

  

Copy to variable replaced query the clipboard by clicking

  

Paste the clipboard text into Compass.

The Query by Example and Report by Example tools also have query copying functions.

Copying a Compass Query into a Qarbine Data Source

In Compass navigate to your query.
Click

  

In the dialog, click the highlighted button.

  

In Qarbine, navigate to the intended Data Source.

Paste the text into the query area.

Importing a Compass Query within the Data Source Designer

You can easily import the local Compass query specifications into the Qarbine Data Designer. Open the Data Source Designer.

First select the data service that corresponds to the database of interest. For example,

  

In the query text area right click for the popup menu and choose the option below.

  

A file dialog is shown.

  

Click the button or drag and drop a Compass query JSON file. Recall the local Compass query folder path is of the form

C:\Users\WINDOWS_USER\AppData\Roaming\MongoDB Compass\SavedPipelines

The dialog is updated similarly as shown below.

  

Click

  

A confirmation dialog is presented.

  

If correct, click

  

The Data Source Designer is updated with the database, collection, and query.

  

The import process expects a JSON file containing a single object. That object must have a pipelineText and name field as well.

Applying Qarbine’s AI Assistant

Query Assistance

The Qarbine sample database includes a simple animals collection.

Describe the query to the AI Assistant.

  

Text to copy is

use the aggregation pipeline to group the animals by type and then sort within each type by age

Click

  

\Wait for a response such as the one shown below.

  

  

Click on the 3 dots and choose the option shown below

  

This sets the query and runs it.

  

It turns out OpenAI missed the mark here.
Let’s add to the context as shown below.

  

Click

  

That result is shown below.

  

With that clarification we can run the updated query. Click on the 3 dots and choose the option shown below

  

This sets the query and rus it.

  

Running the Query in Compass

You can try the query in Compass by copying it via the toolbar button highlighted below.

  

In Compass navigate to your collection of interest.

  

Click the Aggregations tab

  

Click to enter text mode.

  

Paste it into Compass and then remove the leading “db.<collection>.aggregate” text.

  

Click

  

A portion of the results are shown below.

  

To see the details choose the option highlighted below.

  

A portion of the result is shown below.

  

You can save this pipeline query using the options highlighted below.

  

Enter a name

  

Click the Save button.

Saving the Pipeline in a Qarbine Team Folder

As described above the Qarbine catalog can be used to share knowledge across team members through data sources and generic text files within the catalog.

At this point the clipboard should still have the query such as

db.animals.aggregate([
{ $group: { _id: "$type", animals: { $push: "$$ROOT" } } },
{ $unwind: "$animals" },
{ $sort: { "animals.age": 1 } },
{ $group: { _id: "$_id", animals: { $push: "$animals" } } }
])

In the Qarbine catalog, navigate to the folder of interest.

  

Right click and choose the option shown

  

Using the Clipboard’s Contents

If the clipboard has text contents then the first prompt presented is whether to use that as a starting point for the file.

  

In the next dialog

  

enter a component name

  

Optionally enter a description.

  

Click to complete the component creation.

  

Editing the Component

If the clipboard did not have the contents desired then edit the contents. In the catalog select the new component, right click, and choose the option highlighted below.

  

In the dialog, select all of the contents (i.e.,, control-A on Windows).

  

Press delete to clear the text. Edit or otherwise enter the text.

Save the component by clicking

  

This is just one way of many to leverage Qarbine’s shared catalog and AI Assistant features.