Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. mongodb_ecto

mongodb_ecto

Apache-2.0Elixir

An Ecto adapter for MongoDB, enabling Elixir developers to use Ecto's query interface and schema definitions with MongoDB databases.

GitHubGitHub
379 stars126 forks0 contributors

What is mongodb_ecto?

Mongo.Ecto is an adapter that allows the Ecto database wrapper and query generator in Elixir to work with MongoDB databases. It translates Ecto's schema definitions, queries, and operations into MongoDB-compatible commands, enabling developers to use Ecto's familiar abstractions while leveraging MongoDB's document-oriented data model. This solves the problem of integrating MongoDB into Elixir applications without having to abandon Ecto's productivity features.

Target Audience

Elixir developers building applications that use MongoDB as their primary database and want to utilize Ecto for data modeling, validation, and querying. It's particularly useful for teams already invested in Ecto who need to incorporate MongoDB's flexibility.

Value Proposition

Developers choose Mongo.Ecto because it provides a seamless bridge between Ecto's robust, type-safe ecosystem and MongoDB's schema-less design, reducing boilerplate and maintaining consistency across different database backends. Its comprehensive data type mapping and support for modern MongoDB versions ensure reliability and compatibility.

Overview

MongoDB adapter for Ecto

Use Cases

Best For

  • Integrating MongoDB into an existing Elixir Phoenix application that uses Ecto
  • Building new Elixir applications that require both Ecto's abstractions and MongoDB's document storage
  • Migrating an Elixir application from a SQL database to MongoDB while preserving Ecto patterns
  • Leveraging Ecto's query syntax and changesets for MongoDB data validation and manipulation
  • Using MongoDB with Elixir in scenarios requiring complex queries through Ecto's composable API
  • Developing applications that need to switch between SQL and MongoDB backends with minimal code changes

Not Ideal For

  • Applications requiring complex SQL-style joins or ACID transactions, as MongoDB lacks native support and Ecto's abstractions may not fully compensate.
  • Projects heavily utilizing MongoDB-specific features like change streams or geospatial queries without built-in Ecto equivalents.
  • Teams preferring minimal abstraction and direct control over MongoDB driver calls for performance-critical operations.
  • Use cases with highly dynamic, schema-less data that doesn't align well with Ecto's structured schema definitions.

Pros & Cons

Pros

Ecto Query Compatibility

Provides full support for Ecto's query API, migrations, and schema definitions, enabling seamless integration with existing Ecto-based codebases as shown in the example queries.

Comprehensive Data Mapping

Translates BSON data types like object IDs, dates, and binary data to Ecto's type system, ensuring accurate representation with detailed mapping tables in the documentation.

Flexible Connection Options

Supports both key-value configuration and MongoDB connection strings, including mongodb+srv:// for Atlas, simplifying deployment across various environments.

Modern Driver Integration

Built on mongodb_driver and tested against MongoDB 5.0, 6.0, and 7.0, offering robust, up-to-date connectivity with production-ready pool management.

Cons

Breaking Changes in Updates

Migration to version 2.0 required switching drivers and updating direct MongoDB calls, as noted in the migration guide, which can be disruptive for existing projects.

Limited Association Support

Ecto's association features may not map perfectly to MongoDB's document model, complicating relationships and preloading compared to SQL adapters.

Performance Overhead

Using Ecto's layers over MongoDB can introduce overhead for complex queries, and direct driver access is needed for optimizations, adding boilerplate.

Frequently Asked Questions

Quick Stats

Stars379
Forks126
Contributors0
Open Issues21
Last commit1 year ago
CreatedSince 2015

Tags

#query-builder#orm#database-adapter#elixir#driver#no-sql#ecto#schema-definition#data-mapping#mongodb

Built With

E
Ecto
E
Elixir
m
mongodb_driver

Included in

Elixir13.1k
Auto-fetched 18 hours ago

Related Projects

ectoecto

A toolkit for data mapping and language integrated query.

Stars6,460
Forks1,475
Last commit2 days ago
postgrexpostgrex

PostgreSQL driver for Elixir

Stars1,210
Forks302
Last commit4 days ago
eventstoreeventstore

Event store using PostgreSQL for persistence

Stars1,149
Forks155
Last commit13 days ago
redixredix

Fast, pipelined, resilient Redis driver for Elixir. 🛍

Stars1,135
Forks125
Last commit2 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub