Skip to main content

Meteor.js and FerretDB: Using an Open Source MongoDB Alternative for Your Meteor.js Apps

· 6 min read
Alexander Fashakin
FerretDB Team

Meteor.js and FerretDB

Meteor.js has gained immense popularity as a full-stack JavaScript platform for developing modern web and mobile applications, thanks to its seamless data synchronization and full-stack capabilities. Its flexibility, real-time capabilities, and rich ecosystem have made it a developer's favorite.

However, the default database for Meteor.js applications, MongoDB, presents significant concerns about vendor lock-in, especially since its move away from its open-source roots. To mitigate this, open-source alternatives like FerretDB offer the opportunity to seamlessly replace MongoDB without compromising the commands and syntax you already know.

In this article, we'll explore the possible synergy between FerretDB and Meteor.js and how you can build your applications without any concern for lock-in.

Brief History of Meteor.js

Meteor.js is an open-source, all-in-one JavaScript framework, available publicly under the MIT license. Built with Node.js, Meteor.js uses MongoDB as its core database for applications, Blaze handlebars for efficient templating, a powerful pub/sub method for real-time data synchronization, and seamless integration with various Meteor.js plugins, and npm packages you need.

This extensive ecosystem empowers developers to rapidly create quick cross-platform prototypes or large, complex applications with ease. With its open-source nature and availability under the MIT license, Meteor.js has gained popularity among not only mid-sized and enterprise companies like IKEA, Workpop, Accenture but also individual developers and startups.

The framework has been responsible for the development of remarkable apps, such as Rocket.Chat, Apify, and Chatra, among others. Its ability to efficiently handle real-time communication and collaboration make it an ideal platform for applications requiring instant updates and dynamic content.

Meteor.js uses MongoDB as its standard database. However, several concerns about MongoDB over the years have led some to seek (or demand) an open-source alternative that sufficiently replaces MongoDB without any hassles.

Since MongoDB's license switch to SSPL from its former open-source license, there have been growing concerns about the nature of the license and how it may affect developers and companies building their applications with MongoDB. Several Meteor.js application developers are also in this corner.

And this is what makes the announcement of the General Availability version of FerretDB – an open-source replacement to MongoDB – so exciting!

Introducing FerretDB

FerretDB is the defacto open-source MongoDB alternative that converts MongoDB wire protocols with a backend on PostgreSQL. Besides PostgreSQL, FerretDB is also working to provide support for other database backends, such as Tigris, SAP Hana, SQLite, and many more to come.

With the FerretDB GA released in April 2023, users can now leverage FerretDB for their production workloads. Users familiar with MongoDB can seamlessly transition since it uses the same query language and syntax. This makes FerretDB a highly attractive option for Meteor.js developers looking to escape the vendor lock-in challenges associated with MongoDB while still benefiting from a familiar environment.

Some of the popular database management tools, like mongosh, MongoDB Compass, Studio3T, Mingo, and NoSQLBooster, are already capable of taking full advantage of the current set of features on FerretDB.

Apart from these tools, FerretDB is being tested against real-world applications, and some of the major ones are applications built with Meteor.js since they use MongoDB as their default database.

Some of the benefits of using FerretDB with your Meteor.js applications include the following:

  • Open-source nature: With a low barrier to entry, you can get started with FerretDB and take advantage of a community of developers and engineers that's always ready to help and support you every step of the way, without any fear of vendor lock-in.
  • User-friendliness: FerretDB lets you jump in and use the same syntax you're familiar with, so there's no need to learn a new language or syntax; it's the same familiar environment you're already used to.
  • PostgreSQL backend: FerretDB's database engine, PostgreSQL, is renowned for its open-source nature, reliability, and robust community, as well as its ability to handle large amounts of data and complex queries, which can be an added advantage.

Replacing MongoDB With FerretDB in Your Meteor.js Apps

FerretDB has made significant strides in ensuring compatibility with Meteor.js apps, and the development team continues to work on enhancing this compatibility further. As of the latest release, FerretDB demonstrates compatibility with many common MongoDB use cases encountered in Meteor.js applications.

The current level of compatibility enables Meteor.js developers, already accustomed to MongoDB, to seamlessly transition to FerretDB with minimal friction. The same query language and syntax can be directly applied to FerretDB, and this compatibility also extends to MongoDB management tools like Compass, Mingo UI, Studio 3T, etc.

However, please note that while FerretDB strives to achieve comprehensive compatibility with Meteor.js apps, there may be certain edge cases or specific MongoDB features that are not yet fully supported. The FerretDB team is actively addressing these limitations. To stay up to date with the compatibility status and ongoing efforts, please refer to the FerretDB documentation, or take a look at this issue where FerretDB aims to achieve compatibility with Meteor.js examples.

While dealing with these compatibility issues, one of the issues the FerretDB team has grappled with is the challenge of supporting OpLog tailing. The introduction of ChangeStreams in MongoDB 3.6 and later allows real-time data access that bypasses the complications associated with OpLog tailing.

Even though Meteor.js traditionally supports MongoDB's OpLog tailing for real-time data sync, Meteor.js falls back to polling when OpLog is not available; however, while this is not ideal for many production use cases, it can occasionally do the job. At this stage, it's unclear whether the hassles of implementing OpLog will be worth it, especially with a few Meteor.js apps, like Rocket.Chat, moving to ChangeStreams.

Some of the other planned feature additions to help improve compatibility with Meteor.js include support for dot notation in query projections, createIndexes for unique indexes, support for partial indexes, and many more. In addition to these feature additions, FerretDB will also be publishing more blog posts that showcase how different applications can use FerretDB in Meteor.js.

Get Started With FerretDB and Meteor.js

As FerretDB continues to evolve and mature, it is poised to become an even more robust and reliable MongoDB alternative for Meteor.js developers. The FerretDB team is dedicated to ongoing development, bug fixes, and feature implementation to address the needs and feedback of the Meteor.js community.

Check out the FerretDB installation guide or contact us to get started.