Skip to main content

Connecting to Tigris using mongosh

ยท 3 min read
Ovais Tariq

In the previous blog post we discussed using Tigris as a scalable, cost-effective, and open source alternative to MongoDB Atlas. As a continuation of that, this blog post will demonstrate using the MongoDB Shell mongosh in a way that is transparent to the application that the data is stored in Tigris Cloud database.

Furthermore, there will be no cluster to create and no sharding to worry about.

We have also recorded a video if you prefer video content.


Create the Tigris project and generate the application keyโ€‹

Login to Tigris Cloud:

tigris login

Create a Tigris project and generate the application key. The project name will be used as the MongoDB database name. The application key is used to authenticate to Tigris.

tigris create project go_mongo_quickstart
tigris create app_key default --project mongosh_quickstart

The above command will have an output similar to the following:

"id": "your_client_id",
"name": "default",
"secret": "your_client_secret",
"created_at": 1676857746000,
"created_by": "google-oauth2|1111xxx",
"project": "mongosh_quickstart"

Using mongoshโ€‹

Connect to Tigrisโ€‹

We will use the id and secret from the output of the command above as the username and password in our URI. We will use as the deployment to connect to.


Note how you did not have to create a MongoDB Atlas cluster. is a serverless deployment with builtin automatic database sharding, meaning that, unlike MongoDB Atlas, you never have to worry about sharding or shard keys, and the data distribution is automatically handled.

mongosh mongodb:// --quiet --tls

You will see output similar to the following:


Create the databaseโ€‹

Let's create our database mongosh_quickstart

use mongosh_quickstart

You will see output similar to following:

test> use mongosh_quickstart
switched to db mongosh_quickstart

Create a collection and insert a documentโ€‹

Let's create the collection podcasts and insert a document

title: 'The Polyglot Developer Podcast',
author: 'Nic Raboy',
tags: [ 'development', 'programming', 'coding' ]

This results in the following output:

mongosh_quickstart> db.podcasts.insertOne({ title: 'The Polyglot Developer Podcast', author: 'Nic Raboy', tags: [ 'development', 'programming', 'coding' ] })
acknowledged: true,
insertedId: ObjectId("63f8340c6fdb0db31a94bcbf")

We can see that the collection is created:

mongosh_quickstart> show collections

Read all documents in the collectionโ€‹

Let's now read the data in the collection:


This returns all the documents in the collection podcasts:

mongosh_quickstart> db.podcasts.find()
_id: ObjectId("63f8340c6fdb0db31a94bcbf"),
title: 'The Polyglot Developer Podcast',
author: 'Nic Raboy',
tags: [ 'development', 'programming', 'coding' ]

And that's all. Feel free to explore Deletes and Updates similarly.

Tigris is the open source MongoDB Atlas alternative. Offers native support for ACID transactions, automatic database sharding, global secondary indexes, full-text search, high availability, data security, and database branching.

Checkout the quickstarts, give us a star on Github, and join us on Discord.