Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

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

TermsPrivacyAboutGitHubRSS
  1. Home
  2. MongoDB
  3. mongodb_ecto

mongodb_ecto

Apache-2.0Elixir

MongoDB adapter for Ecto, enabling Elixir applications to use MongoDB as a data store with Ecto's query interface.

GitHubGitHub
379 stars126 forks0 contributors

What is mongodb_ecto?

Mongo.Ecto is an adapter that integrates MongoDB with Ecto, Elixir's database wrapper and query generator. It allows developers to leverage MongoDB's document-oriented database capabilities while using Ecto's familiar schema definitions, queries, and changesets.

Target Audience

Elixir developers building applications that require MongoDB as a backend, particularly those already using or familiar with Ecto for database interactions.

Value Proposition

Developers choose Mongo.Ecto to use MongoDB's flexible document model within Elixir's Ecto ecosystem, maintaining compatibility with Ecto conventions while supporting MongoDB-specific features like BSON data types and connection strings.

Overview

MongoDB adapter for Ecto

Use Cases

Best For

  • Integrating MongoDB into Elixir applications that use Ecto for database abstraction.
  • Building Elixir applications that require document-oriented data storage with Ecto's query DSL.
  • Migrating existing Elixir Ecto-based projects to use MongoDB as the database backend.
  • Leveraging MongoDB-specific data types like regular expressions and JavaScript within Ecto schemas.
  • Connecting to MongoDB versions 5.0, 6.0, or 7.0 from Elixir using Ecto's adapter interface.
  • Using Ecto's schema definitions and changesets with MongoDB collections and field mappings.

Not Ideal For

  • Projects requiring direct and unfiltered access to MongoDB's native aggregation pipeline or change streams
  • Teams that heavily rely on dynamic, schema-less data models where Ecto's structured schemas become restrictive
  • Applications needing frequent database backend switches between SQL and NoSQL with minimal code changes
  • Systems where performance-critical operations depend on low-level MongoDB driver features not exposed by Ecto

Pros & Cons

Pros

Seamless Ecto Integration

Enables use of Ecto's query DSL and changesets with MongoDB, as shown in the example with `from w in Weather`, allowing developers to leverage familiar Elixir patterns.

Comprehensive BSON Type Mapping

Supports MongoDB-specific data types like regular expressions and JavaScript through custom Ecto types such as `Mongo.Ecto.Regex`, detailed in the README's mapping table.

Flexible Connection Configuration

Allows setup via key-value options or MongoDB connection strings (e.g., mongodb://), providing adaptability for different deployment environments, as per the configuration examples.

Active Maintenance and Testing

Regularly tested against MongoDB versions 5.0, 6.0, and 7.0, with CI badges and recent updates indicating reliable support and compatibility.

Cons

Breaking Driver Changes

The migration to version 2.0 required updates from the old `mongodb` driver to `mongodb_driver`, disrupting direct driver calls and pool handling, as noted in the migration guide.

Ecto Abstraction Limitations

Some MongoDB-native features, like advanced aggregation pipelines or real-time change streams, are not fully accessible through Ecto's interface, potentially requiring workarounds.

Schema Rigidity Overhead

Ecto's schema definitions enforce a structure that may conflict with MongoDB's flexible document model, complicating handling of highly nested or dynamic data without custom mappings.

Frequently Asked Questions

Quick Stats

Stars379
Forks126
Contributors0
Open Issues21
Last commit1 year ago
CreatedSince 2015

Tags

#orm#bson#database-adapter#elixir#ecto#data-mapping#mongodb#elixir-library

Built With

E
Ecto
E
Elixir
m
mongodb_driver

Included in

MongoDB2.6k
Auto-fetched 18 hours ago

Related Projects

mongodbmongodb

MongoDB driver for Elixir

Stars567
Forks150
Last commit8 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