Tigris MongoDB compatibility now in beta

Phil Leggetter - Mar 22 '23 - - Dev Community

MongoDB compatibility has been added to the Tigris open source developer data platform and is now also available on Tigris Cloud.

The first beta release of Tigris MongoDB compatibility offers support for MongoDB 6.0+ CRUD and Aggregation operations. Any application that uses the supported MongoDB CRUD and Aggregation operations, no matter the programming language, can now use Tigris instead of a self-hosted MongoDB instance or MongoDB Atlas.

Demonstrating Tigris MongoDB compatibility

CRUD operations for all MongoDB drivers that support MongoDB 6.0+ work with Tigris, so all you need to do for your MongoDB application to use the Tigris MongoDB compatibility feature is to update the database connection string.

Let's quickly demonstrate this using the official MongoDB TypesScript example. The simplest way to follow along is to signup for a Tigris Cloud account and create your first project, calling it gamesDB .

Clone the repo and install the application dependencies:

git clone https://github.com/mongodb-developer/mongodb-typescript-example.git
cd mongodb-typescript-example
npm i
Enter fullscreen mode Exit fullscreen mode

Copy the .env.example file and create a new .env file:

cp env.example .env;
Enter fullscreen mode Exit fullscreen mode

Update the .env file replacing the contents of the DB_CONN_STRING variable with the following:

"mongodb://{TIGRIS_CLIENT_ID}:{TIGRIS_CLIENT_SECRET}@m1k.preview.tigrisdata.cloud:27018?authMechanism=PLAIN&tls=true";
Enter fullscreen mode Exit fullscreen mode

Replace {TIGRIS_CLIENT_ID} and {TIGRIS_CLIENT_SECRET} within the connection string with the application credentials from the project you have created in Tigris Cloud. Finally, Update the value of DB_NAME with the name of the project you created in Tigris Cloud.

And run the app:

npm start
Enter fullscreen mode Exit fullscreen mode

You'll see output similar to the following:

[INFO] 15:12:35 ts-node-dev ver. 1.1.8 (using ts-node ver. 9.1.1, typescript ver. 4.3.5) Successfully connected to database: gamesDB and collection: gamesServer started at http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

Now, make a few cURL requests to test it out. First, create a resource:

curl --location --request POST 'http://localhost:8080/games' \--header 'Content-Type: application/json' \--data-raw '{ "name": "Fable Anniversary", "price": 4.99, "category": "Video Game"}'
Enter fullscreen mode Exit fullscreen mode

Then list the resources:

curl --location --request GET 'http://localhost:8080/games'
Enter fullscreen mode Exit fullscreen mode

It's that simple! You can check out our MongoDB examples on GitHub for more examples.

If you have any questions about using Tigris MongoDB compatibility or have feedback to help us prioritize additional compatibility, join the Tigris Discord Community, or get in touch.

An open source alternative to MongoDB Atlas

Tigris is an open source alternative to MongoDB Atlas. We've released the MongoDB compatibility feature to make it easier for you to migrate MongoDB applications over to Tigris and benefit from the following:

  • A truly serverless database : There's no need for cluster provisioning or capacity planning. Create a project, obtain your application keys, and you're ready to go.
  • Automatic database sharding : Tigris provides automatic database sharding, and shard keys are unnecessary as the data distribution is automatically handled. This includes both sharding and optimizing the number of shards. MongoDB Atlas requires you to specify and manage sharding to horizontally scale. With Tigris, you get more time to focus on developing applications for your users.
  • Cost-efficient and unlimited scalability : Unlike MongoDB Atlas, Tigris can scale to millions of records read and written per second and petabytes of data storage at a fraction of the cost.
  • Strong data consistency : The storage layer is built on FoundationDB, and Tigris inherits the strong consistency guarantees. Tigris provides global, interactive, ACID transactions with strict serializability using optimistic concurrency control. Tigris also provides strongly consistent global secondary indexes that enable powerful querying capabilities by any field.
  • Global secondary indexes: Tigris offers transactionally consistent global secondary indexes allowing quick lookups by any field.
  • Full-text search: Tigris integrates a database, search engine, and synchronization mechanism in a unified platform. This provides the fastest way to add search capabilities to your applications. Tigris provides a rich query DSL, fuzzy search, custom ranking, fast faceting, and geo search.
  • Cloud-native architecture : Tigris follows a modern composable architecture with loosely coupled components. Furthermore, compute is separated from storage, allowing for independent scaling and a more resilient system.
  • Bring your own cloud : Tigris' open source Kubernetes-native design allows it to be deployed anywhere in the cloud in your own VPC, so that all the data is contained in your own environment.

How MongoDB compatibility works and what's next

Tigris leverages the FerretDB library to provide compatibility with the wire protocol for MongoDB, which enables transparent compatibility with native MongoDB client SDKs, drivers, and tools. Tigris doesn't host the MongoDB database engine. Any MongoDB client driver compatible with version 6.0+ should be able to connect with no special configuration. We are actively working on testing the compatibility with all MongoDB drivers.

Tigris Architecture

We plan to improve compatibility beyond the currently supported CRUD and Aggregation operations.

For more information, see our MongoDB compatibility docs. For details on the Tigris architecture, see our Architecture docs.

Beyond MongoDB and MongoDB Atlas

We're excited that the Tigris MongoDB compatibility feature has moved into beta today, but we have a bigger vision that we're working towards.

With that in mind, we recommend that the Tigris SDKs, not the MongoDB drivers, are used for greenfield applications or new application features. By doing so, you'll benefit from the native Tigris functionality, which simplifies the development process by enabling a code-first and agile approach to database schema definition and removes the need for an ORM/ODM. In addition, by using the native Tigris SDKs, you will also benefit from the full value of a data developer platform and get Search and other products we launch through a unified API.

Get started with Tigris

The quickest way to try out the Tigris MongoDB compatibility is to signup for a Tigris Cloud account and follow one of the Tigris MongoDB compatibility quickstarts.

If you have any questions or you'd like to contribute to theTigris open source project it would be great to see you in the Tigris Discord Community. For anything else, get in touch.

. . . . . . . . . . . . . . . . . . . . . .