cortfritz

cortfritz

I’m working on a project that uses :mongodb_driver (GitHub - zookzook/elixir-mongodb-driver: MongoDB driver for Elixir · GitHub). I use Ecto changesets but not full ecto queries. I’d like to be able to use libraries that use Ecto so I am looking into adding full Ecto via :mongodb_ecto. :mongodb_driver README says it has supported Ecto since v1.4.0.

I picked this driver some time ago as the repo seemed more alive. This driver also provides watch_collection which allows my elixir service to respond to changes in mongo.

:mongdb_ecto seems typically to use :mongodb, a different driver.

:mongdb_ecto expects the struct Mongo.Query to have the key :extra. :mongodb has this key in that struct, :mongodb_driver does not.

I’m using current versions, and have tried combinations of older versions but have not found a combination where this works.

I’m considering forking :mongodb_ecto to handle this, on the presumption that whatever :extra is doing I can work around it or bypass it as I don’t need it. If I find something elegant I can offer PR. I’m also asking :mongodb_driver maintainers if I can contribute, in which case I’ll figure out what work :extra is doing and submit a PR that supports it.

Maybe someboy else has figured this out and I can do something similar to what they did and not have to do the above.

Alternatively, maybe somebody has a different idea altogether. I’m open. I’m even willing to discuss at length “why aren’t you just using Postgres” which I expect from this joyus community. I might even find a path to that less costly than anything else, and projects like GitHub - mathieuprog/polymorphic_embed: Polymorphic embeds in Ecto · GitHub make this more tenable. But for now presume that I’d just like to learn how :mongodb_driver works with :mongodb_ecto, like I believe that it says it does.

Showing Posts 1 to 8

cortfritz

cortfritz OP

[:cricket:, :cricket:]

al2o3cr

al2o3cr

FWIW, there’s already a PR that claims to switch mongodb_ecto to use mongodb_driver from January:

https://github.com/elixir-mongo/mongodb_ecto/pull/190

However, I agree with your assessment that the extra key will cause problems - particularly in Mongo.Ecto.Connection.format_query where every head expects a Mongo.Query to have that key:

https://github.com/elixir-mongo/mongodb_ecto/blob/83587c2c5d14f5956ad78ffaba62630515e44e06/lib/mongo_ecto/connection.ex#L477-L484

cortfritz

cortfritz OP

Matt, thank you. It looks like that PR removes extra: from the Struct and comments out code that references that key or its value. Going to try it.

rhcarvalho

rhcarvalho

I tried using :mongodb_ecto for some time but reverted to using the zookzook driver directly. The driver can model collections, and I can create something like an ecto repo that starts up with the application.

I can still use Ecto.Changeset where it makes sense. I found this setup much more stable.

cortfritz

cortfritz OP

Yes j started with that.

But I want to use frameworks that depend on Ecto and generate queries with adapter- and so on. So I also want to get Ecto working.

cortfritz

cortfritz OP

For example phx.gen.live

rhcarvalho

rhcarvalho

I see. In my case I was dealing with multiple repos, SQL-based and MongoDB. Trying to use Ecto with mongo had so many caveats that I felt it was only getting in the way. I’d rather write MongoDB queries directly and have access to aggregation operations.

For this particular case, have you considered customizing the templates?

cortfritz

cortfritz OP

haven’t considered that! Considering now, thank you.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews